Motion UIComponentsComponent

Swipe actions

A list row that follows a swipe to reveal actions, and commits on a full flick.

npx shadcn@latest add @motion/swipe-actions

API reference

Components

<SwipeActionsList />

List container that coordinates single-open state across rows.

children?

ReactNode

The SwipeActions rows.

className?

string

Merged onto the <ul>.

style?

CSSProperties

Inline styles merged onto the <ul>.

ref?

Ref<HTMLUListElement>

Forwarded to the <ul>.

<SwipeActions />

One swipeable row with pointer/drag machinery and spring follow.

id

string

Stable id for this row. Required.

children?

ReactNode

The row face that slides over the actions.

left?

ReactNode

Actions revealed by swiping the row right.

right?

ReactNode

Actions revealed by swiping the row left.

rowHeight?

number = 88

Row height in px. Defaults to 88.

revealThreshold?

number = 0.25

Fraction of the row a swipe must clear to snap open. Defaults to 0.25.

fullSwipeThreshold?

number = 0.8

Fraction of the row a swipe must clear to commit a full swipe. Defaults to 0.8.

revealAmount?

number = 0.5

How far the row snaps open, as a fraction of its width. Defaults to 0.5.

index?

number = 0

This row's position in the list, for the entrance stagger. Defaults to 0.

isLast?

boolean = false

Drop the bottom divider on the last row. Defaults to false.

className?

string

Merged onto the row <li>.

<SwipeAction />

A single revealed action with elastic offset/scale as the swipe crosses.

icon

ReactNode

The action glyph.

label

string

The short action label.

side

SwipeSide

Which edge this action lives on.

primary?

boolean = false

Whether this is the outer primary action on its side. Defaults to false.

fillClassName

string

Fill and text classes for this action's box.

ariaLabel

string

The button's accessible label.

onActivate

() => void

Fired when the action is tapped or a full swipe commits it.

Hooks

useSwipeRow

Read the enclosing row's live swipe state from a face.

useSwipeRow(): SwipeRowState

Returns

progress

MotionValue<number>

Live swipe progress in [-1, 1].

spring

TransitionToken

The snap spring the row follows with.

flat

boolean

True under reduced motion.

Related examples