Components

Button Group

A React button group built on shadcn/ui: join buttons, inputs and select triggers into one control with shared borders, horizontal or vertical — plus Motion blocks for a split button that rolls to the action you pick and a segmented button group with a sliding active indicator.

  • Drop-in shadcn API
  • Server Component friendly
  • Horizontal & vertical
  • Split button
  • Motion blocks

Installation

$ npx shadcn@latest add https://duskui.com/r/button-group.json

CSS only — no "use client" needed. Works with any button, but is tuned for the DuskUI Button: joined segments sink by a pixel instead of scaling, so seams never split.

Usage

pager.tsx
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"

export function Pager() {
  return (
    <ButtonGroup aria-label="Pagination">
      <Button variant="outline">Previous</Button>
      <Button variant="outline">Next</Button>
    </ButtonGroup>
  )
}

Examples

Nested groups

A ButtonGroup of ButtonGroups becomes a toolbar with gaps between sets. ButtonGroupText adds a non-interactive segment.

3 / 12

Orientation & separators

orientation="vertical" stacks the buttons. Filled variants have no border, so put a ButtonGroupSeparator between them.

With input & select

Inputs stretch to fill the group, and select triggers join seamlessly.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Animated Button Group

Joined outline buttons where a quiet indicator slides to the selected segment. It's a radio group under the hood: one Tab stop, arrow keys and Home / End move the selection, and the value can be submitted with a form.

$ npx shadcn@latest add https://duskui.com/r/animated-button-group.json
PropTypeDefaultDescription
options{ value; label?; icon?; aria-label?; disabled? }[]—Segments. Icon-only segments need an aria-label.
value / onValueChangestring / (v: string) => void—Controlled value.
defaultValuestring—Uncontrolled initial value. Defaults to the first option.
size"sm" | "default" | "lg""default"Button size.
orientation"horizontal" | "vertical""horizontal"Layout and arrow-key axis.
namestring—Submit the value with a hidden input.

Split Button

A primary action joined to a menu of alternatives. Picking another option makes it the main action: its label rolls in while the button springs to the new width, and the chevron flips while the menu is open.

$ npx shadcn@latest add https://duskui.com/r/split-button.json
PropTypeDefaultDescription
actions{ value; label; description?; icon?; disabled? }[]—The menu options. The selected one runs from the main button.
value / onValueChangestring / (v: string) => void—The selected action (controlled).
onAction(value: string) => void—Main button click, with the selected action.
variant"default" | "secondary" | "outline""default"Button style.
loadingbooleanfalseSpinner on the main button.
menuLabelstring"More options"Accessible name of the chevron button.

API Reference

Each part accepts the props of the element it renders.

PropTypeDefaultDescription
ButtonGroup orientation"horizontal" | "vertical""horizontal"Direction the segments join in.
ButtonGroupText asChildbooleanfalseRender your own element, e.g. a <label>.
ButtonGroupSeparator orientation"vertical" | "horizontal""vertical"Use horizontal inside vertical groups.

Accessibility

  • ButtonGroup renders role="group" — give it an aria-label that names the set.
  • Focused segments rise above their neighbours, so focus rings are never clipped.
  • The Animated Button Group is a radiogroup with roving tabindex and arrow-key selection.
  • The Split Button menu is a Radix Dropdown Menu with radio items, so it has full keyboard support and announces the checked option.
  • Indicators and label rolls respect prefers-reduced-motion.