Split Button
A primary action with a chevron that opens related variants; picking one makes it the new default action.
$
View as Markdownnpx shadcn@latest add https://sundaeui.dev/r/split-button.jsonOverview
The main half runs the current action. The chevron half opens a menu of alternatives, each with a short description. Choosing one runs it and, optionally, remembers it as the default, so the label morphs to match.
Common for Merge / Squash / Rebase, Save / Save as draft, Send / Schedule.
When to use
- A primary action with a few closely related alternatives.
When not to use
- Unrelated actions: use a plain menu.
Installation
$
pnpm dlx shadcn@latest add https://sundaeui.dev/r/split-button.json$
npx shadcn@latest add https://sundaeui.dev/r/split-button.json$
yarn dlx shadcn@latest add https://sundaeui.dev/r/split-button.json$
bunx --bun shadcn@latest add https://sundaeui.dev/r/split-button.jsonWorks in any React project. Files are written to components/sundae/. Read the source in the stage’s Code view.
- No dependencies beyond React 18 or later.
- Copy split-button.tsx and split-button.css into components/sundae/.
- The CSS file is imported by the component, so no extra configuration is needed.
- Import the component and use it as shown below.
Usage
import { SplitButton } from '@/components/sundae/split-button'
<SplitButton />Props
| Prop | Type | Default |
|---|---|---|
actions*Actions; the first is the default. | { id: string; label: string; detail?: string }[] | — |
onActionCalled when an action runs. | (id: string) => void | — |
rememberMake the last chosen action the default. | boolean | true |
fillSurface: dark or light. | 'dark' | 'light' | 'dark' |
Accessibility
- Two buttons in a group: the action, and a menu button with aria-haspopup and aria-expanded.
- The menu uses role="menuitemradio" with the default checked.
- Reduced motion removes the movement and keeps every state change.
Customization
- Colours are CSS custom properties on .sd-spb; override them in your own stylesheet.
- fill="light" switches the built-in light palette.
Keyboard
- ↓ (on chevron)
- Open menu
- ↑ / ↓
- Move
- Esc
- Close
FAQ
- Is Split Button free?
- Yes. Split Button is free for personal and commercial projects, with full source on this page.
- How do I install Split Button?
- Run npx shadcn@latest add https://sundaeui.dev/r/split-button.json. The files are written to components/sundae/. It has no dependencies beyond React 18 or later.
- Does Split Button support keyboard and screen readers?
- Two buttons in a group: the action, and a menu button with aria-haspopup and aria-expanded. The menu uses role="menuitemradio" with the default checked.
- Does Split Button respect reduced motion?
- Reduced motion removes the movement and keeps every state change.
More like this
All components →Speed Dial
Components · RefinedHold to Confirm
Components · RefinedFollow Button
Components · RefinedDownload Button
Components · RefinedBookmark Button
Components · RefinedSnooze Menu
Components · Refined