How it works
Two native buttons sit inside one rounded shape, separated by a hairline seam. Each half has its own hover and press layer, so it is always clear which part will act. The chevron opens a role="menu" that grows from its corner with a short ease-out, and the chevron itself turns with a spring. Items can carry an icon, a one-line description, a shortcut hint or a danger tone.
Use it for
- One action is clearly the most common and a few variations of it are needed, such as Publish with Schedule and Save as draft.
- Toolbars and footers where space allows only one button.
Look elsewhere when
- The actions are equally important: show them as separate buttons.
- More than about seven actions: use a full menu or a page.
Usage
import { SplitButton } from './SplitButton.jsx'
export function PublishActions({ onPublish, onSchedule, onSaveDraft, onDiscard }) {
return (
<SplitButton
label="Publish"
menuLabel="More publish options"
onClick={onPublish}
items={[
{ id: 'schedule', label: 'Schedule…', description: 'Pick a date and time', onSelect: onSchedule },
{ id: 'draft', label: 'Save as draft', shortcut: '⌘D', onSelect: onSaveDraft },
{ divider: true },
{ id: 'discard', label: 'Discard changes', danger: true, onSelect: onDiscard },
]}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
label | ReactNode | — | Text of the primary action. |
onClick | (event) => void | — | Runs the primary action. |
items | Array<{ id, label, description?, icon?, shortcut?, danger?, disabled?, divider?, onSelect? }> | [] | Menu entries. An entry with divider: true draws a separator. shortcut is shown only, it does not bind keys. |
onSelect | (item) => void | — | Called with the chosen item, after the menu closes. |
variant | 'primary' | 'ink' | 'secondary' | 'primary' | Colour. |
size | 'sm' | 'md' | 'lg' | 'md' | Height 32, 40 or 44px. |
align | 'start' | 'end' | 'end' | Which edge the menu lines up with. |
side | 'bottom' | 'top' | 'bottom' | Opens the menu below or above, for buttons in footers. |
menuLabel | string | 'More options' | Accessible name of the chevron and the menu. |
loading | boolean | false | Shows a spinner on the primary half and disables it; the menu still works. |
disabled | boolean | false | Disables both halves. |
Accessibility
- The primary half and the chevron are separate native buttons; the chevron has aria-haspopup="menu", aria-expanded and an accessible name from menuLabel.
- ArrowDown or ArrowUp on the chevron opens the menu on the first or last item; in the menu, arrows wrap, Home and End jump, typing a letter jumps to a matching item.
- Enter or Space chooses; Escape closes and returns focus to the chevron; Tab or clicking outside closes.
- Items use role="menuitem" with roving tabindex; disabled items are skipped and carry aria-disabled.
- Reduced motion replaces the menu's scale with a fade and stops the chevron turning.
Motion
The menu fades in and grows from 96% over 240ms ease-out, from the chevron's corner. The chevron turns 180° in 240ms with a slight spring overshoot.
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.
SplitButton.jsxsplit-button.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.



