Split Button

SplitButton is a two-part control: a wide default action button beside a narrow chevron that opens a role="menu" of related actions. It is built from plain buttons with keyboard and focus behaviour included and needs only lucide-react, with no radix-ui dependency.

Split Button
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

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

Requires @pulld in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { SplitButton } from "@/components/ui/split-button"<SplitButton label="Save" actions={[{ label: "Save as draft", onSelect: () => console.log("draft") }]} />
  • Use when a screen has one obvious action plus two or three close variants of it, such as Save and Save as draft, Merge and Squash and merge, or Export CSV and Export XLSX.
  • Use when the default action should stay one click away while the less common alternatives stay in the same place rather than on another screen.
  • Use when the default action may need to be unavailable while the menu remains usable, such as a form that cannot be saved yet but can be saved as a draft.
  • Do not use for a single action that asks for confirmation (use confirm-button), a busy action (use loading-button), or a searchable list of values (use a select component).

Examples

Save with a draft option

A default Save action with one related action in the menu. The menu label reads "More Save options" for assistive technology.

save-with-a-draft-option.tsx
import { SplitButton } from "@/components/ui/split-button"export function SaveBar() {  return (    <SplitButton      label="Save"      actions={[        { label: "Save as draft", onSelect: () => console.log("draft") },        { label: "Save and close", onSelect: () => console.log("close") },      ]}    />  )}

Merge with the default action unavailable

actionDisabled disables only the default action, so the menu stays usable for closing or squashing the pull request.

merge-with-the-default-action-unavailable.tsx
import { SplitButton } from "@/components/ui/split-button"export function MergeButton({ canMerge }: { canMerge: boolean }) {  return (    <SplitButton      label="Merge"      actionDisabled={!canMerge}      actions={[        { label: "Squash and merge", onSelect: () => console.log("squash") },        { label: "Rebase and merge", onSelect: () => console.log("rebase"), disabled: true },        { label: "Close pull request", onSelect: () => console.log("close") },      ]}    />  )}

Outline variant with an icon and aligned menu

The outline variant shares one border between the halves. The menu aligns to the start edge and items take icons.

outline-variant-with-an-icon-and-aligned-menu.tsx
import { Download, FileText } from "lucide-react"import { SplitButton } from "@/components/ui/split-button"export function ExportButton() {  return (    <SplitButton      label="Export CSV"      variant="outline"      align="start"      actions={[        { label: "Export XLSX", icon: <FileText />, onSelect: () => console.log("xlsx") },        { label: "Export PDF", icon: <Download />, onSelect: () => console.log("pdf") },      ]}    >      <Download />      Export CSV    </SplitButton>  )}

Custom localized arrow name

labels.more rewrites the arrow's accessible name in any language, receiving the default action's label.

custom-localized-arrow-name.tsx
import { SplitButton } from "@/components/ui/split-button"export function JapaneseSplitButton() {  return (    <SplitButton      label="保存"      labels={{ more: (label) => `${label}のその他の操作` }}      actions={[{ label: "下書きとして保存", onSelect: () => console.log("draft") }]}    />  )}

API reference

PropTypeDefaultDescription
labelstring—Required. The default action's text unless children is given, and the source of the arrow's accessible name.
childrenReact.ReactNode—Content of the default action when it needs more than label, such as an icon or a badge.
actionsreadonly SplitButtonAction[]—Items shown in the menu. Each item is { id?: string, label: string, onSelect: () => void, disabled?: boolean, icon?: React.ReactNode }. An empty list renders no arrow. A disabled item uses aria-disabled and remains reachable by keyboard.
variant"primary" | "outline" | "destructive""primary"Visual style of both halves, including the divider each style needs.
align"start" | "end""end"Which edge of the unit the menu lines up with. Follows the document direction.
type"button" | "submit" | "reset""button"Applies to the default action only. The arrow is always type="button".
disabledbooleanfalseDisables both the default action and the arrow.
actionDisabledbooleanfalseDisables only the default action, leaving the menu usable.
menuDisabledbooleanfalseDisables only the arrow, leaving the default action pressable.
onOpenChange(open: boolean) => void—Called once per change when the menu opens or closes, reported from an effect.
labelsPartial<SplitButtonLabels>defaultSplitButtonLabelsOverrides the arrow's accessible name. more receives the label and returns the name, for example (label) => `More ${label} options`.
classNamestring—Applied to the wrapper element.
buttonClassNamestring—Applied to the default action button.
triggerClassNamestring—Applied to the arrow button.
menuClassNamestring—Applied to the menu panel.
itemClassNamestring—Applied to each menu item.

Accessibility

  • The arrow is a button with aria-haspopup="menu", aria-expanded reflecting the open state, and aria-controls pointing at the menu while it is open.
  • The arrow's accessible name is built from the default action's label, for example "More Save options", so repeated split buttons remain distinguishable.
  • The arrow is always type="button" so it never submits a surrounding form, regardless of the type prop.
  • ArrowDown and ArrowUp on either half open the menu. Focus moves into the menu onto the first or last item, and arrow keys wrap at both ends.
  • Home and End move to the first and last items. Escape, Tab, and choosing an item close the menu and return focus to the half that opened it.
  • An outside pointer press closes the menu without moving focus, so the user's click target is preserved.
  • Menu items use role="menuitem" with a roving tabIndex, so only the focused item is in the tab order.
  • Disabled menu items use aria-disabled rather than the disabled attribute, so they stay in the arrow-key sequence and are announced as unavailable.
  • Icons inside the menu and the chevron are aria-hidden. The visible label carries the meaning.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Split Button" component (pulld/split-button) from its shadcn registry.1. Install it with: npx shadcn@latest add @pulld/split-button2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: label, children, actions, variant, align, type, disabled, actionDisabled, menuDisabled, onOpenChange, labels, className, buttonClassName, triggerClassName, menuClassName, itemClassName.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { SplitButton } from "@/components/ui/split-button"<SplitButton label="Save" actions={[{ label: "Save as draft", onSelect: () => console.log("draft") }]} />```

Files & dependencies

  • registry/ui/split-button.tsx
dependencieslucide-react

Looks similar, elsewhere