Action Swap Roll

Rolls between button states.

Installation

pnpm dlx shadcn@latest add @paneui/action-swap-roll

Usage

Examples

Copy With Reset

Sizes

Controlled

Custom Slots

Use the slots when you need your own button layout or slot order.

Motion

The roll springs at 460 / 32 / 0.55 and exits take 150ms. With reduced motion they cross-fade and the width snaps.

Action Swap Blur has the same API with a blur and holds the shared engine.

API Reference

ActionSwapRollButton

A Button that advances through items on click, rolling its icon and label. Also accepts every prop of Button.

items*
ActionSwapItem[]
States in order, each { value: string; label: ReactNode; icon?: ReactNode; ariaLabel?: string }.
value
string
Controlled current item value.
defaultValue
string
Initial item value. Defaults to the first item.
onValueChange
(value: string, item: ActionSwapItem) => void
Called when the current item changes, including on reset.
iconOnly= true for `icon*` sizes
boolean
Hide the label and swap only the icon slot.
cycle= true
boolean
Advance to the next item on click.
resetAfter
number
Milliseconds after which the button returns to its first item.
PropTypeDefaultDescription
items*ActionSwapItem[]—States in order, each { value: string; label: ReactNode; icon?: ReactNode; ariaLabel?: string }.
valuestring—Controlled current item value.
defaultValuestring—Initial item value. Defaults to the first item.
onValueChange(value: string, item: ActionSwapItem) => void—Called when the current item changes, including on reset.
iconOnlybooleantrue for `icon*` sizesHide the label and swap only the icon slot.
cyclebooleantrueAdvance to the next item on click.
resetAfternumber—Milliseconds after which the button returns to its first item.

ActionSwapRollText

Label slot that rolls to new content when value changes. Also accepts every prop of span.

value*
string
Identity of the current label.
children*
ReactNode
The label.
className
string
Classes for the slot.
PropTypeDefaultDescription
value*string—Identity of the current label.
children*ReactNode—The label.
classNamestring—Classes for the slot.

ActionSwapRollIcon

16px icon slot that rolls to the new glyph. Also accepts every prop of span.

value*
string
Identity of the current icon.
children*
ReactNode
The icon.
className
string
Classes for the slot.
PropTypeDefaultDescription
value*string—Identity of the current icon.
children*ReactNode—The icon.
classNamestring—Classes for the slot.