Skip to content

    Browse components

    Swipe Action

    List row you swipe right to archive or left to delete, with rubber-band resistance, an armed pop past the threshold and a collapse on commit. Arrow keys + Enter work too.

    Open
    Customize

    Installation

    npx shadcn@latest add @glint-ui/swipe-action

    First time using @glint-ui? Add the registry to components.json once, or install by URL: npx shadcn@latest add https://glintui.vercel.app/r/swipe-action.json

    Usage

    import { SwipeAction } from "@/components/ui/swipe-action";
    
    {mails.map((m) => (
      <SwipeAction
        key={m.id}
        label={m.subject}
        onArchive={() => archive(m.id)}
        onDelete={() => remove(m.id)}
      >
        <MailPreview mail={m} />
      </SwipeAction>
    ))}

    Props

    PropTypeDefaultDescription
    thresholdnumber110Px the row must travel to commit on release.
    actionWidthnumber80Width of the revealed action when the row rests half open.
    archiveColorstring"#22c55e"Right-swipe action color.
    deleteColorstring"#ef4444"Left-swipe action color.
    archiveLabelstring"Archive"Right-swipe action label.
    deleteLabelstring"Delete"Left-swipe action label.
    labelReactNode—Accessible name of the row.
    onArchiveReactNode—Called after the row swipes out and collapses. Omit to disable right swipe.
    onDeleteReactNode—Called after the row swipes out and collapses. Omit to disable left swipe.
    classNamestring—Extra classes for the root element.