Action Swap Roll
Rolls between button states.
Installation
pnpm dlx shadcn@latest add @paneui/action-swap-rollUsage
Examples
Motion
The roll springs at 460 / 32 / 0.55 and exits take 150ms. With reduced motion they cross-fade and the width snaps.
Related
Action Swap Blur has the same API with a blur and holds the shared engine.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
| 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 | boolean | true for `icon*` sizes | Hide the label and swap only the icon slot. |
| cycle | boolean | true | Advance to the next item on click. |
| resetAfter | number | — | 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string | — | Identity of the current label. |
| children* | ReactNode | — | The label. |
| className | string | — | 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string | — | Identity of the current icon. |
| children* | ReactNode | — | The icon. |
| className | string | — | Classes for the slot. |