Xzero UI
Pro library

Swipe actions

Reveal row actions with a swipe, or from the same actions in a menu.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/swipe-actions
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/swipe-actions

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { SwipeActions, SwipeActionsRow } from "@/components/xzero/swipe-actions/swipe-actions";
import { Archive, MailOpen } from "lucide-react";

export function Inbox({ messages }: { messages: Message[] }) {
  return (
    <SwipeActions label="Inbox">
      {messages.map(message => (
        <SwipeActionsRow
          key={message.id}
          label={message.subject}
          leading={[{ label: "Unread", icon: <MailOpen size={18} />, tone: "accent", keepRow: true, onSelect: () => markUnread(message.id) }]}
          trailing={[{ label: "Archive", icon: <Archive size={18} />, tone: "danger", onSelect: () => archive(message.id) }]}
        >
          <MessagePreview message={message} />
        </SwipeActionsRow>
      ))}
    </SwipeActions>
  );
}

API reference

SwipeActions

The list. Keeps one row open at a time and closes it on an outside press or Escape.

PropTypeDefaultDescription
label (required)string–Accessible name for the list.
children (required)ReactNode–SwipeActionsRow elements. Removing one animates its height closed.
classNamestring–Extra class on the surface.

SwipeActionsRow

One row whose actions reveal under its left and right edges on a horizontal swipe.

PropTypeDefaultDescription
label (required)string–Names the row's More actions button, for example the message subject.
leadingSwipeAction[][]Actions under the left edge, revealed by swiping right. The first one commits on a full swipe.
trailingSwipeAction[][]Actions under the right edge, revealed by swiping left. The last one commits on a full swipe.
fullSwipebooleantrueLets a long swipe or flick commit the outermost action.
children (required)ReactNode–Row content.
classNamestring–Extra class on the row.

SwipeAction

One action in leading or trailing.

PropTypeDefaultDescription
label (required)string–Shown under the icon and in the menu.
icon (required)ReactNode–Action icon.
onSelect (required)() => void–Runs on full swipe, tap, or menu choice. Remove the item here unless keepRow is set.
tone"neutral" | "accent" | "danger""neutral"Fill of the revealed action.
keepRowboolean–Springs the row home after the action instead of sliding it away.

Keyboard interactions

KeysAction
Enter / SpaceOpens a row's More actions menu from its button.
ArrowDown / ArrowUpMoves between the row's actions in the menu.
EscapeCloses the menu or puts away an open row.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in gestures

Guidance for AI tools

Swipe actions: Reveal row actions with a swipe, or from the same actions in a menu. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components