Swipe actions (Pro)
ProIncluded in $99Swipe a message or a thread for retry, copy, pin or delete, with a commit line for a long swipe and a small bump when you cross it.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { SwipeActions } from "@/components/ui/chatcn/pro/swipe-actions"
<SwipeActions
leading={[{ id: "pin", label: "Pin", icon: <PinIcon />, tone: "amber", onAction: pin }]}
trailing={[
{ id: "archive", label: "Archive", icon: <ArchiveIcon />, onAction: archive },
{ id: "delete", label: "Delete", icon: <TrashIcon />, tone: "red", onAction: remove }, // a long swipe runs this one
]}
>
<ThreadRow thread={thread} />
</SwipeActions>The row follows the finger and the actions slide out from under it, spreading as it goes. Let go past half of the actions' width, or flick, and it rests open; tap the row to close it. Keep going past the commit line (60% of the row) and the outer action takes the whole strip, its icon gives a small bump and the device vibrates briefly where it can; let go and the row slides away, the action runs and the row comes back. Everything moves on one critically damped spring driven frame by frame, so a new touch catches the row mid flight. Only a clearly sideways move starts a swipe, so lists still scroll. One row is open at a time. For keyboards, a menu button with the same actions appears when the row is tabbed into. Physical directions follow right to left layouts.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
leading | SwipeAction[] | The start side; the first is what a long swipe runs |
trailing | SwipeAction[] | The end side; the last is what a long swipe runs |
menu | boolean | The keyboard menu. Default true |
disabled | boolean | No swiping |
labels | { more } | The menu button's name |
Keyboard
| Key | Action |
|---|---|
| Tab | Shows the actions menu button for the row |
| Enter | Opens the menu |
Accessibility
- The swipe strip is decoration; the same actions are real menu items for keyboards and screen readers.
- Name the menu button per row through
labels.more. - Colors follow the kit's meanings: red for delete, amber for pin, never color alone.
Motion
A critically damped spring, about 350 ms to rest, carrying the release velocity. Under reduced motion rows jump to rest and nothing vibrates.