Expandable Control

Button or chip that expands on click to reveal a label.

@paneui/theme@base-ui/reactmotion

Installation

pnpm dlx shadcn@latest add @paneui/expandable-control

Usage

Examples

Controlled

Chip Actions

Prevent Toggle

Keyboard

Both parts expose aria-expanded. In a chip, Escape tucks the action away and returns focus to the chip; after an action runs, focus also returns to the chip.

Motion

The width springs between natural sizes (300 / 24 / 0.8). With reduced motion the width changes instantly and the revealed part only fades.

API Reference

Built on the Button primitive. Only the props this library adds or changes are listed; everything else passes through.

ExpandableButton

Icon button that grows to reveal its label on click. Also accepts every prop of Button.

icon*
ReactNode
Always visible.
label*
ReactNode
Revealed beside the icon when expanded.
expanded
boolean
Controlled expanded state.
defaultExpanded= false
boolean
Initial expanded state.
onExpandedChange
(expanded: boolean) => void
Called when it toggles.
aria-label= label, if a string
string
Accessible name (the label itself is aria-hidden).
PropTypeDefaultDescription
icon*ReactNode—Always visible.
label*ReactNode—Revealed beside the icon when expanded.
expandedboolean—Controlled expanded state.
defaultExpandedbooleanfalseInitial expanded state.
onExpandedChange(expanded: boolean) => void—Called when it toggles.
aria-labelstringlabel, if a stringAccessible name (the label itself is aria-hidden).
data-expanded
Present while expanded (primary fill).
Data attributeDescription
data-expandedPresent while expanded (primary fill).

ExpandableChip

Chip that reveals a trailing action button when clicked.

label*
ReactNode
The chip's text; clicking it toggles the action.
actionIcon*
ReactNode
Icon in the revealed action button.
actionLabel*
string
Accessible name for the action, e.g. "Remove Design".
onAction
() => void
Called when the action is clicked.
collapseOnAction= true
boolean
Collapse (and return focus to the chip) after the action runs.
actionTone= "default"
"default" | "destructive"
Visual tone of the action.
expanded
boolean
Controlled expanded state.
defaultExpanded= false
boolean
Initial expanded state.
onExpandedChange
(expanded: boolean) => void
Called when it toggles.
disabled= false
boolean
Disable the chip and its action.
className
string
Classes for the chip.
PropTypeDefaultDescription
label*ReactNode—The chip's text; clicking it toggles the action.
actionIcon*ReactNode—Icon in the revealed action button.
actionLabel*string—Accessible name for the action, e.g. "Remove Design".
onAction() => void—Called when the action is clicked.
collapseOnActionbooleantrueCollapse (and return focus to the chip) after the action runs.
actionTone"default" | "destructive""default"Visual tone of the action.
expandedboolean—Controlled expanded state.
defaultExpandedbooleanfalseInitial expanded state.
onExpandedChange(expanded: boolean) => void—Called when it toggles.
disabledbooleanfalseDisable the chip and its action.
classNamestring—Classes for the chip.
data-expanded
Present while the action is shown.
data-disabled
Present when disabled.
Data attributeDescription
data-expandedPresent while the action is shown.
data-disabledPresent when disabled.