Split Button
ProNewA default action joined to a caret that lists its alternatives, with an optional description for each.
Installation
pnpm dlx shadcn@latest add @viewport/split-button
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| children* | React.ReactNodeThe label of the main action. | — |
| onClick | () => voidRuns when the main part is pressed. | — |
| items* | SplitButtonItem[]The alternatives listed under the caret. | — |
| menuLabel | stringAccessible name of the caret button. | "More options" |
| variant | "primary" | "outline" | "primary" |
| size | "sm" | "md" | "lg" | "md" |
| loading | booleanPuts the main action in its loading state. The menu stays available. | — |
| disabled | boolean | — |
| className | string | — |
Accessibility
- Two separate buttons, each with its own name and focus ring.
- The menu is a Radix Dropdown Menu: arrow keys, typeahead and Escape.
- The main action can show a loading state while the menu stays available.
- Respects prefers-reduced-motion.