Split button

Free

One glass body with two hit areas: the main action and a chevron for its options, split by a hairline, each half with its own hover and press.

npx shadcn@latest add @pixilui/split-button

Preview

One glass body with two hit areas, each with its own press.
Show

When to use

Use it when

  • An action people repeat with a usual choice and a few others: Deploy to production, or to staging.
  • A picker that also acts: the current branch, with the switcher behind the chevron.

Use something else when

  • Options that are equal: use a menu button or a segmented control.
  • A single action with no options: use Button.

Installation

Terminal
npx shadcn@latest add @pixilui/split-button

Adds split-button.tsx with button.tsx, and installs clsx and tailwind-merge. First PixilUI item in this app? Add the registry once, as in Installation.

Usage

example.tsx
import { SplitButton } from "@/components/pixilui/split-button";

<SplitButton
  menuIcon={menuIcon}
  menuLabel={menuLabel}
  onAction={onAction}
  onMenu={onMenu}
>Save changes</SplitButton>

Sizes to its label and never grows past its container. Both halves keep a 40px hit area on desktop and 44 on touch.

API reference

PropTypeDefault
childrenRequiredReactNode–The main action's label.
menuIconRequiredReactNode–The menu half's icon, usually a chevron.
menuLabelRequiredstring–The menu half's accessible name ("Deploy options").
variant"primary" | "secondary"–primary for the main action of a surface (Deploy), secondary for a picker (a branch).
sizeButtonSize–Height, as on Button: xs 24, sm 28, md 32 (default), lg 36, xl 44.
iconReactNode–Leading icon of the main action.
onAction(event: MouseEvent<HTMLButtonElement>) => void | Promise<void>–Runs the main action.

Also takes every native <div> attribute except onClick, and a ref.

Keyboard

TabMoves focus to the action, then to the menu half.
EnterRuns the focused half: the action, or opening the menu.
SpaceRuns the focused half on release.

Accessibility

  • A group of two native buttons; name the group with aria-label ("Deploy").
  • The menu half needs menuLabel ("Deploy options"); its icon is aria-hidden.
  • When a popover or menu owns the menu half, pass its trigger props through menuProps so aria-expanded and aria-controls land on that button.

Motion

  • Each half presses on its own: scale .96 in 150ms ease-out, with the glass setting in.
  • Hover in 150ms lights only the half under the pointer.
  • Reduced motion: no press scale; colour changes stay.

PixilUI Pro opens Thu 10 Dec. The first 20 licenses are $99.