Button Group Split Demo
A split-button example that joins a secondary text Button and a square icon-only Button (PlusIcon) inside ButtonGroup.Root, with a ButtonGroup.Separator between them. It shows the common 'primary action plus more action' pattern.
Installation
Requires @kanpeki in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { PlusIcon } from "lucide-react";import { Button } from "~/registry/ui/button";import { ButtonGroup } from "~/registry/ui/button-group";export function ButtonGroupSplitDemo() { return ( <ButtonGroup.Root> <Button variant="secondary">Button</Button> <ButtonGroup.Separator /> <Button size="icon" variant="secondary"> <PlusIcon /> </Button> </ButtonGroup.Root> );}- Showing a main action next to a compact secondary action, such as 'Add' with a plus icon beside it
- Grouping related actions into one visually connected control in toolbars or form footers
- Creating a split-button layout where a label and an icon button share one edge
- Demonstrating the ButtonGroup.Separator API in documentation or a component gallery
Examples
Split button with a click handler
Adds onClick handlers to both segments of the split button so the text action and the icon action trigger different behavior.
import { PlusIcon } from "lucide-react";import { Button } from "~/registry/ui/button";import { ButtonGroup } from "~/registry/ui/button-group";export function CreateSplitButton() { return ( <ButtonGroup.Root> <Button variant="secondary" onClick={() => console.log("create")}> New item </Button> <ButtonGroup.Separator /> <Button size="icon" variant="secondary" aria-label="Add another item" onClick={() => console.log("add")} > <PlusIcon /> </Button> </ButtonGroup.Root> );}Split button with an accessible icon label
Adds an aria-label to the icon-only segment so screen readers announce its purpose.
import { PlusIcon } from "lucide-react";import { Button } from "~/registry/ui/button";import { ButtonGroup } from "~/registry/ui/button-group";export function AccessibleSplitButton() { return ( <ButtonGroup.Root> <Button variant="secondary">Button</Button> <ButtonGroup.Separator /> <Button size="icon" variant="secondary" aria-label="Add"> <PlusIcon /> </Button> </ButtonGroup.Root> );}Accessibility
- The icon-only Button in the source has no visible text and no aria-label, so add aria-label (for example aria-label="Add") to it in production code.
- Keep the text Button label descriptive so its purpose is clear without the icon.
- Use real button elements (as Button provides) so the group is keyboard focusable with Tab and activatable with Enter or Space.
- ButtonGroup.Separator is a visual divider in the demo; do not rely on it to communicate meaning to assistive technology.
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.
Use the "Button Group Split Demo" component (kanpeki/button-group-split-demo) from its shadcn registry.1. Install it with: npx shadcn@latest add @kanpeki/button-group-split-demo2. 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.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { PlusIcon } from "lucide-react";import { Button } from "~/registry/ui/button";import { ButtonGroup } from "~/registry/ui/button-group";export function ButtonGroupSplitDemo() { return ( <ButtonGroup.Root> <Button variant="secondary">Button</Button> <ButtonGroup.Separator /> <Button size="icon" variant="secondary"> <PlusIcon /> </Button> </ButtonGroup.Root> );}```Files & dependencies
- src/registry/examples/button-group/button-group-split-demo.tsx
Looks similar, elsewhere
There is no screenshot of this item to compare yet.