Swipe Actions
Swipe a row in a list to reveal actions on the left or right.
Features
Built on top of React Swipe Actions.
- Drag with pointer or touch, or open a focused row with the arrow keys.
- Snaps open on distance or a flick. A full swipe runs the action outright.
- Only one row open at a time, dismissed by
Escapeor an outside click. - Keeps closed strips
inertand respectsprefers-reduced-motion.
Installation
pnpm dlx shadcn@latest add @ncdai/swipe-actions
Usage
import {
SwipeAction,
SwipeActions,
SwipeContent,
SwipeItem,
SwipeRoot,
} from "@/components/swipe-actions"<SwipeRoot>
<SwipeItem>
<SwipeActions side="right">
<SwipeAction />
<SwipeAction fullSwipe />
</SwipeActions>
<SwipeContent />
</SwipeItem>
</SwipeRoot>Composition
Use the following composition to build a SwipeItem
SwipeRoot
└── SwipeItem
├── SwipeActions
│ └── SwipeAction
└── SwipeContentExamples
Minimal
The smallest setup that works: one action on one side.
Choosing the full swipe action
fullSwipe can sit on any action in the strip. Put it on the safe one so a
destructive action still needs a deliberate tap.