Swipe actions
Reveal actions on either edge, or commit an action with a full swipe.
Your flight to New York is ready.
Swipe either way. Swipe fully left to delete, or use an actions button.
Installation
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/swipe-actions.jsonThe registry includes the shared styles and dependencies. Import @/components/apple-ui/styles.css in your root layout once. For the package route, use the installation guide.
Usage
const deleteAction = {
label: "Delete",
tone: "destructive" as const,
onAction: remove,
};
<SwipeActions
label="Boarding pass"
leadingActions={[{ label: "Archive", onAction: archive }]}
actions={[deleteAction]}
fullSwipe={{ edge: "trailing", action: deleteAction }}
>
<ListItem title="Boarding pass" supportingText="Madrid to New York" />
</SwipeActions>Package imports use @eduardoul/apple-ui. Registry imports use @/components/apple-ui. Add "use client" to files that use state or event handlers.
API reference
| Property | Type | Default |
|---|---|---|
| actions | SwipeAction[] on the trailing edge | required |
| leadingActions | SwipeAction[] on the leading edge | [] |
| fullSwipe | { edge: SwipeEdge; action: SwipeAction; threshold?: number } | undefined |
| fullSwipe.threshold | fraction of row width, clamped to 0.55 through 0.9 | 0.72 |
| label | string | required |
Use className and style to customize the component. The package includes full TypeScript definitions for its supported element properties and refs.
Design guidance
- Use a small set of short actions so each remains easy to reach. Leading and trailing edges follow the layout direction.
- The buttons provide both sets of actions without requiring a gesture. Escape closes the open tray.
- Full swipe is optional. Pass the same action object in its edge array and fullSwipe configuration. Release beyond the threshold commits after the departure animation.
- A full swipe must travel at least 24 pixels beyond the tray width. Reversing or canceling the gesture prevents the commit. The application owns removal and undo behavior.
Accessibility
Provide a visible label or accessible name. Keep keyboard focus visible and check the example with your content at 200 percent zoom. Overlays use Radix for focus management and keyboard dismissal.
Library styles support reduced motion, reduced transparency, increased contrast and forced colors. Read the accessibility foundation for the checks your application still needs.