Skip to content
Haze UI

Swipe actions

A list whose rows slide sideways to reveal leading and trailing actions, with a full-swipe shortcut, a More actions menu and undo.

pnpm dlx shadcn@latest add @haze/swipe-actions
Open preview in a new tab
Livesmall script

When to use

  • An inbox or task list on touch screens needs quick archive, snooze or mark-read actions on each row.
  • A destructive shortcut should need a deliberate long swipe, with Undo as the safety net.

When not to use

  • Use dropdown-menu for one set of actions that belongs to a single trigger, not to every row of a list.
  • Use sortable-list when the gesture should reorder items rather than reveal actions.

Installation

Add the Haze registry to components.json once, then install Swipe actions with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/swipe-actions
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique caller supplied prefix for the control and its associated content.
namestringid-actionFallback submit button name; each value combines row and action identifiers.
labelstringTeam inboxAccessible name for the row list.
items{ id: string; label: string; description?: string }[]Three demo inbox rowsRows with stable identifiers and concise readable content.
leading{ id: string; label: string; tone?: "neutral" | "accent" | "danger"; keepRow?: boolean; icon?: "archive" | "mail-open" | "clock" | "trash" }[]Mark read (accent, keepRow)Actions revealed under the left edge by swiping right; the first one is the full-swipe action. keepRow springs the row back instead of removing it.
trailing{ id: string; label: string; tone?: "neutral" | "accent" | "danger"; keepRow?: boolean; icon?: "archive" | "mail-open" | "clock" | "trash" }[]Snooze (neutral, keepRow) / Archive (accent, removes the row)Actions revealed under the right edge by swiping left; the last one is the full-swipe action.
classstring–Additional classes on this component's outer wrapper.

Keyboard interactions

EnterSpace on More actions
Open the row's action menu and focus its first action.
Arrow UpArrow DownHomeEnd
Move between actions in the open menu.
Escape
Close the menu and return focus to More actions, or close an open swiped row.

Accessibility

  • The gesture is a shortcut only: revealed action buttons are aria-hidden and out of the tab order, and every row has a visible More actions button with the same actions.
  • The More actions menu is a native popover: Enter or Space opens it, Arrow keys, Home and End move between actions, Escape closes it and returns focus to the button.
  • Horizontal intent is locked after about 6 px before pointer capture, so vertical touch movement keeps scrolling the page; text selection is blocked while dragging.
  • Only one row stays open. A press outside the row or Escape closes it; reduced motion jumps to the stops and fades removed rows instead of animating height.
  • After a removing action, focus moves to the next row's More actions button, or to Undo when no rows remain; a status region names the affected row.
  • Without script the menu buttons submit row:action through the enclosing form; enhanced consumers listen for the cancelable haze:swipe-action event, and Undo emits haze:swipe-undo.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Swipe actions" with `npx shadcn@latest add @haze/swipe-actions`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import SwipeActions from "@/components/haze/ui/swipe-actions.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/swipe-actions.md

  • Customize with real content

    Adapt the Haze swipe-actions ui for our product. Replace the demo values of these props with our real content: id, name, label, items, leading, trailing, class. Keep the layout, the heading level rules and these accessibility details: The gesture is a shortcut only: revealed action buttons are aria-hidden and out of the tab order, and every row has a visible More actions button with the same actions. The More actions menu is a native popover: Enter or Space opens it, Arrow keys, Home and End move between actions, Escape closes it and returns focus to the button. Horizontal intent is locked after about 6 px before pointer capture, so vertical touch movement keeps scrolling the page; text selection is blocked while dragging. Only one row stays open. A press outside the row or Escape closes it; reduced motion jumps to the stops and fades removed rows instead of animating height. After a removing action, focus moves to the next row's More actions button, or to Undo when no rows remain; a status region names the affected row. Without script the menu buttons submit row:action through the enclosing form; enhanced consumers listen for the cancelable haze:swipe-action event, and Undo emits haze:swipe-undo. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using swipe-actions, check it fits: use it when an inbox or task list on touch screens needs quick archive, snooze or mark-read actions on each row.; a destructive shortcut should need a deliberate long swipe, with undo as the safety net.. Avoid it when use dropdown-menu for one set of actions that belongs to a single trigger, not to every row of a list.; use sortable-list when the gesture should reorder items rather than reveal actions.. Alternatives: @haze/dropdown-menu, @haze/sortable-list, @haze/card-stack.

Dependencies

  • npm: @lucide/astro
  • @haze/button
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog