Skip to content

Expanding button group

Icon buttons in a compact group: the one you point at or focus grows to reveal its label while its neighbours slide aside, and an action confirms in place.

ActionGroupToolbarNew
npx shadcn@latest add @silicon-ui/expanding-button-group

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/expanding-button-group

Manually

  1. Install the dependencies

    npm install motion
  2. Copy these files into your project

    • components/silicon-ui/expanding-button-group/expanding-button-group.tsx
    • components/silicon-ui/expanding-button-group/expanding-button-group.module.css
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { ExpandingButtonGroup } from "@/components/silicon-ui/expanding-button-group/expanding-button-group";

API reference

PropTypeDefault
items*readonly ExpandingButtonGroupItem[]—
label*

Accessible name of the toolbar, such as "Message actions".

string—
sizeExpandingButtonGroupSize

"sm""md"

"md"
defaultExpanded

Id of the action whose label shows at rest, usually the primary one. Defaults to the first enabled action: one action is always expanded. Pointing at or focusing another moves the expansion there, and it returns here when the pointer and focus leave.

string | nullnull
onAction

Called with the item id whenever an action runs, before its own onSelect.

(id: string) => void—
confirmDuration

How long the confirmation stays, in milliseconds.

number1400
classNamestring—
styleCSSProperties—

Dependencies

npm
motion
Registry
silicon-motion-tokens