Swipe actions
A list row that slides over its actions: cells grow with your finger, a full swipe runs the first one, and the row folds away.
Used forEmail and inbox listsTask and to-do listsNotification and message listsOrder and ticket queues
Install with the shadcn CLI
Older shadcn CLI, or a network that blocks ui.shadcn.com? Install by URL: shadcn add https://hairlineui.com/r/swipe-actions.json. More
Templates
Need the whole page?
65 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.
Where it’s used
Email and inbox lists
Swipe to archive, delete or mark as read.
Task and to-do lists
Complete or snooze a task with a swipe.
Notification and message lists
Quick actions on each row.
Order and ticket queues
Handle many items quickly on a phone.
What it handles for you
Most web lists copy swipe actions badly: a row that slides to show two buttons and nothing more. This works the way mail apps do, and has buttons for people who don’t swipe.
Actions that grow with your finger
The cells under the edge share the space the row uncovers, and each icon scales in once there is room.
A full swipe runs the first action
Keep going past most of the row and the first action arms, taking the whole space. Letting go runs it.
Trackpads work too
A two-finger swipe on a trackpad drives the row in the same way.
Removal that can fail
A removing action slides the row off and folds it away. If it fails, the row comes back, shakes and reads Failed.
Buttons for a mouse
With a fine pointer, hovering or focusing the row shows the same actions as icon buttons. This is the accessible path.
One row open at a time
Opening one row closes the other, and a tap on an open row closes it.
Overview
Most web lists copy swipe actions badly: a row that slides to show two buttons and nothing more. This one works the way mail apps do. Drag a row, or swipe two fingers on a trackpad, and the actions under that edge share the space it uncovers: every cell grows with the finger and its icon scales in once there is room. Let go past half the rail and the row springs open; keep going past most of the row and the first action arms, taking the whole space with its icon riding the row's edge, and letting go runs it. Actions that remove the row slide it off and fold its height away at once, and if the work fails the row unfolds, slides back and shakes. With a mouse the row's time gives way to the same actions as icons on hover, so nothing depends on the gesture.
States
- reveal
- After 7px of mostly horizontal movement the row follows the pointer on one transform; vertical movement is left to the page. The cells under that edge share the uncovered space equally, and each icon scales from 0.72 and fades in as its cell passes about 50px.
- open
- Released past half the rail (76px per action), or flicked outward faster than 0.45px/ms, the row springs open; otherwise it springs closed. Tapping the row, pointing anywhere else, Escape or opening another row closes it.
- arm
- Past 62% of the row the first action takes over the whole space in about 60ms and its icon rides the row's edge, with a 6ms vibration on phones. Coming back 24px disarms it. Releasing while armed runs it.
- remove
- An action with removes slides the row off (critically damped) and folds its height in 380ms before onAction settles. If onAction throws, the row unfolds, springs back, shakes and its time reads Failed for 2.6s.
- hover
- On devices with a fine pointer, hovering or focusing the row fades the time out and the actions in as 28px icon buttons over a soft edge of the row's own colour.
Usage
An inbox where delete can fail
Removal is optimistic: the row leaves as soon as the swipe commits. Throw from onAction to bring it back; take the item out of your list once it resolves.
Props
- label
- string
- Names the row for screen readers and in announcements, e.g. the subject.
- leading
- SwipeAction[]
- Under the left edge, revealed by swiping right. The first runs on a full swipe.
- trailing
- SwipeAction[]
- Under the right edge, listed from the edge inward. The first runs on a full swipe.
- SwipeAction
- { id, label, icon, tone?, removes?, onAction }
- tone is "neutral" (muted), "primary" or "destructive". removes slides the row off and folds it away; onAction may return a promise and throw to undo that.
- meta
- ReactNode
- At the row's end, e.g. the time. Gives way to the action icons on hover.
- enter= false
- boolean
- Unfold on mount, for a row put back by an undo.
- divider= true
- boolean
- A hairline under the row that folds away with it. Clip the last one with -mb-px on the list.
- disabled= false
- boolean
- No gestures and no actions.
Accessibility and motion
- The icon buttons are the accessible actions: they are real buttons in the tab order, shown on hover or focus, with the action as their name. The swipe cells repeat them for pointers and are hidden from assistive technology.
- Results are announced in a status region: done, or failed with an invitation to try again. Escape closes an open row.
- Only one row is open at a time, as in mail apps. A tap on an open row closes it instead of following whatever is under it, and a click that ends a drag is swallowed.
- Drags and trackpad swipes write transforms only, and one frame loop runs the spring and the arming, then sleeps. Each cell is a full-height layer moved by transform, so revealing never changes layout.
- Reduced motion turns springs, folds and the shake into immediate changes; the colours, labels and announcements still say what happened.
Requirements
React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.
Source
Registry item: /r/swipe-actions.json


