Swipe Actions

Swipe a list row left or right to reveal configurable actions.

@lucide/sveltemotion-svruned

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/swipe-actions.json

Examples

Minimal

Reveal a destructive action by swiping a list row to the left.

  • components.json
  • registry.json
  • tailwind.config.ts

Props

SwipeRoot

Coordinates a group so only one swipe item remains open.

NameTypeDefaultDescription
childrenSnippetrequiredSwipe items rendered inside the root.
refHTMLDivElement | nullnullBindable reference to the root element.
classClassValueundefinedAdditional classes applied to the root element.

SwipeItem

A swipeable row that owns gesture state and snap behavior.

NameTypeDefaultDescription
childrenSnippetrequiredAction strips and foreground content rendered inside the item.
thresholdnumber0.5Fraction of an action strip the drag must pass to snap open.
velocityFactornumber0.2Seconds of pointer velocity projected onto the release position.
fullSwipeThresholdnumber0.5Fraction of the row width required to arm a full-swipe action.
disabledbooleanfalseDisables pointer and keyboard swiping.
closeOnScrollbooleanfalseCloses an open item when the page scrolls.
onOpenChange(state: SwipeState) => voidundefinedCalled when the item settles closed, left, or right.
refHTMLDivElement | nullnullBindable reference to the item element.
classClassValueundefinedAdditional classes applied to the item.

SwipeActions

Action strip revealed on one side of a swipe item.

NameTypeDefaultDescription
childrenSnippetrequiredActions rendered in DOM order inside the strip.
side"left" | "right"requiredSide of the row from which actions are revealed.
fullSwipebooleanfalseLets a drag across the row invoke the outermost action.
refHTMLDivElement | nullnullBindable reference to the action strip.
classClassValueundefinedAdditional classes applied to the action strip.

SwipeAction

Styled action button displayed inside an action strip.

NameTypeDefaultDescription
childrenSnippetrequiredIcon and label rendered inside the action.
closeOnClickbooleantrueCloses the item after the click handler runs without being prevented.
onclick(event: MouseEvent) => voidundefinedRuns when the action is clicked or invoked by a full swipe.
refHTMLButtonElement | nullnullBindable reference to the action button.
classClassValueundefinedAdditional classes applied to the action button.

SwipeContent

Draggable foreground content that reveals the action strips.

NameTypeDefaultDescription
childrenSnippetrequiredVisible row content moved by the swipe gesture.
styleMotionStylePropsundefinedAdditional Motion styles merged with the horizontal motion value.
refHTMLDivElement | nullnullBindable reference to the draggable content.
classClassValueundefinedAdditional classes applied to the content.