Skip to Content
NarakUI

Split Button

A button that runs the most common action, joined to a menu of related alternatives.

Primary

SplitButton.Root is a Dropdown.Root. Put the leading SplitButton.Action, the chevron SplitButton.Trigger and an ordinary Dropdown.Content inside it. The trigger shows only an icon, so give it an aria-label.

Secondary with options

Without mode, both halves use the secondary button style. The menu can change what the action does. Here it picks which checks run, and keeps itself open while you toggle them.

Ghost

Use mode="ghost" inside toolbars. Hovering either half also tints the other, so the pair reads as one control. Remove the root's shadow with shadow-none when it sits on a flat surface.

Sizes

size on the root applies to both halves.

Disabled and loading

disabled on the root disables both halves. Each half also takes its own disabled, and the action takes the button's loading prop. Disable the trigger while the action is loading so the menu cannot start a second run.

Give SplitButton.Action an href to render it as a link.

Installation

pnpm dlx shadcn@latest add @narakui/split-button

Add "@narakui": "https://ui.narakcode.dev/r/{name}.json" to components.json, or install directly from https://ui.narakcode.dev/r/split-button.json.

Usage

import { Dropdown } from '@/components/ui/dropdown-menu';
import { SplitButton } from '@/components/ui/split-button';

<SplitButton.Root mode="primary">
  <SplitButton.Action iconStart="plus" onClick={create}>
    Create
  </SplitButton.Action>
  <SplitButton.Trigger aria-label="More ways to create" />
  <Dropdown.Content align="end">
    <Dropdown.Item onSelect={importFile}>Import from a file</Dropdown.Item>
  </Dropdown.Content>
</SplitButton.Root>;

SplitButton.Root Properties

PropTypeDefaultDescription
mode'primary' | 'secondary' | 'tertiary' | 'ghost' | 'subtle' | 'destructive' | 'dashed''secondary'Button style shared by both halves
size'micro' | 'small' | 'regular' | 'large''regular'Button size shared by both halves
disabledbooleanfalseDisables both halves
openboolean—Whether the menu is open, when controlled
defaultOpenboolean—Whether the menu starts open, when uncontrolled
onOpenChange(open: boolean) => void—Called when the menu opens or closes
modalbooleanfalseWhether the open menu blocks interaction with the rest of the page. Always true inside a dialog or drawer
classNamestring—Additional classes for the wrapper around both halves

SplitButton.Action Properties

PropTypeDefaultDescription
childrenReactNode—Label of the action
hrefstring—Renders the action as a link to this destination
iconStartButtonIconValue—Icon before the label
loading{ isLoading?: boolean; className?: string }—Shows a spinner in place of the icon and disables the action
disabledboolean—Disables the action. Defaults to the root's disabled
modeButtonMode—Overrides the root's mode for this half
sizeSplitButtonSize—Overrides the root's size for this half
classNamestring—Additional classes for the action. Other Button props are passed through

SplitButton.Trigger Properties

PropTypeDefaultDescription
aria-labelstringRequiredAccessible name of the icon-only menu trigger, such as More ways to create
iconStartButtonIconValue'chevron-down'Icon of the trigger
disabledboolean—Disables the trigger. Defaults to the root's disabled
modeButtonMode—Overrides the root's mode for this half
sizeSplitButtonSize—Overrides the root's size for this half
classNamestring—Additional classes for the trigger. Other Button props are passed through