Swipe actionsNew
A row that makes room for its next step. Swipe to reveal, then choose what happens.
Install with the shadcn CLI
Overview
Keep secondary actions close without making every row a toolbar. A horizontal swipe moves the foreground aside, with a little resistance at either end and a sampled spring on release. Actions stay explicit: swiping reveals them, clicking performs them. Each callback owns its real work and reports pending, success or retry in the same button.
States
- reveal
- After 8px of horizontal intent, the row follows the pointer on one transform. Vertical scrolling remains available.
- settle
- Reveal more than 45% of the action rail to leave it open. A 420ms sampled spring settles either way.
- perform
- An explicit action click runs its callback once. The button morphs through pending and success, then the row closes after 1300ms.
- retry
- A rejected callback leaves the actions open with a Retry button. Another click attempts the operation again.
Usage
Works with
Let the application own the result
Resolve after the operation succeeds, or reject to leave a retry available. Use one to three short actions; row content can contain ordinary links and controls.
Props
| Prop | Type | Description |
|---|---|---|
| actions | SwipeAction[] | id, label, optional icon, disabled, pendingLabel and successLabel, plus an async or synchronous onAction callback. |
| label | string | Accessible name for this row and its actions toggle. |
| children | ReactNode | The foreground row. Interactive children keep their normal behaviour. |
| disabled | booleandefault false | Disables gestures, the reveal button and all actions. |
Accessibility and motion
- The three-dot button reveals actions without a gesture. Tab reaches each button; Escape closes the rail and returns focus.
- Closed actions are inert and hidden from assistive technology. Leaving the row with keyboard focus closes it.
- A swipe never performs an action. Vertical touch scrolling wins when the first movement is predominantly vertical.
- The gesture measures its action rail once, then writes only the foreground transform. There are no React renders per move.
- Reduced motion removes the release spring. Callback state labels and checks follow Status button’s reduced-motion behaviour.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
The CLI also installs Status button.
Source
Registry item: /r/swipe-actions.json