---
title: "Swipe Actions"
description: "A list row that people swipe sideways to show actions under it, as in a mail app. A full swipe runs the main action, and every action is also a button."
url: https://gelatinui.com/components/swipe-actions
markdown_url: https://gelatinui.com/components/swipe-actions.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/swipe-actions"
version: "2026-11-11"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Swipe Actions

> A list row that people swipe sideways to show actions under it, as in a mail app. A full swipe runs the main action, and every action is also a button.

Page: https://gelatinui.com/components/swipe-actions

## When to use it

Best for: Lists on touch screens where each row has two or three quick actions people use often.

- Use it for the actions people repeat many times a day on rows of a list.
- Use `primary` on the action that a full swipe runs, and `dismiss` on an action that removes the row.
- Use `SwipeActionsGroup` so that one row is open at a time.

## When not to use it

- For one action that needs a firm yes, such as a payment, use a [Swipe to Confirm](https://gelatinui.com/components/swipe-to-confirm.md).
- For a mouse-first table with many actions, put them in a [Context Menu](https://gelatinui.com/components/context-menu.md).
- To swipe whole cards away one at a time, use a [Swipe Deck](https://gelatinui.com/components/swipe-deck.md).

## Notes for agents

- Compose `SwipeActions` > `SwipeActionsContent` (the row) and one `SwipeActionsTray` per side, each with `SwipeAction` buttons.
- `side` is `leading` or `trailing` and follows the text direction.
- A full swipe runs the `primary` action of that side. Set `fullSwipe={false}` to stop at the tray.
- A `dismiss` action slides the row out and closes its height, then calls `onDismiss` on the root: remove the item there.
- `event.preventDefault()` in an action `onClick` keeps the row as it is (ask first, then send `row.dismiss` with `useSwipeActionsActor`).
- Pass `bg-card` to `SwipeActionsContent` in a card, or the trays show through.
- Rows in a list keep their space inside the row (a border), not in a list `gap`, so a dismissed row closes with no jump.

## Anatomy

```text
SwipeActions
├─ SwipeActionsRootProvider (0..n)
├─ SwipeActionsContent (0..n)
├─ SwipeActionsTray (0..n)
├─ SwipeAction (0..n)
└─ SwipeActionsGroup (0..n)
```

## API reference

### SwipeActions

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `SwipeActionsSide \| null` |  | The open tray (controlled). `null` is closed. |
| `defaultOpen` | `SwipeActionsSide \| null` |  | The tray that is open at first (uncontrolled). |
| `onOpenChange` | `function` |  |  |
| `disabled` | `boolean` |  | No swipe and no trackpad swipe; the actions leave the Tab order. |
| `fullSwipe` | `boolean` |  | A swipe past the commit point runs the `primary` action of that side. Default `true`. |
| `onDismiss` | `function` |  | Called after a `dismiss` action slid the row out and closed its height: remove the item. |
| `driverRef` | `Ref<DragDriver \| null>` |  | Drives a swipe from code (`DragDriver`, no item): a staged scene or a test grabs the row, carries it, and lets go, and the row's own release rules open a tray, commit, or close. |

### SwipeActionsContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `ref` | `Ref<HTMLDivElement>` |  |  |
| `children` | `ReactNode` |  |  |

### SwipeActionsTray

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `ref` | `Ref<HTMLDivElement>` |  |  |
| `side` | `SwipeActionsSide` |  | The side of the row: `leading` (start) or `trailing` (end). It follows the text direction. |
| `children` | `ReactNode` |  |  |

### SwipeAction

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `ref` | `Ref<HTMLButtonElement>` |  |  |
| `tone` | `"destructive" \| "info" \| "neutral" \| "primary" \| "success" \| "warning"` |  |  |
| `primary` | `boolean` | false | The action that a full swipe runs on its side (the edge one in a mail app). |
| `dismiss` | `boolean` | false | After `onClick`, slide the row out and call the root's `onDismiss` (a delete, an archive). |
| `children` | `ReactNode` |  |  |

### SwipeActionsGroup

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| SwipeActions | `swipe-actions` |  |  |  |
| SwipeActionsRootProvider | `swipe-actions` |  |  |  |
| SwipeActionsContent | `swipe-actions-content` |  | `--swipe-actions-x` |  |
| SwipeActionsTray | `swipe-actions-tray` |  | `--swipe-actions-opacity`, `--swipe-actions-x` |  |
| SwipeAction | `swipe-action` | `data-commit`, `data-side` | `--swipe-actions-x` | `status-colors` |
| SwipeActionsGroup | `swipe-actions-group` |  |  |  |

## Usage

Put the row in `SwipeActionsContent`, and the actions in a tray per side.

```tsx title="mail-row.tsx"
import { ArchiveIcon, EnvelopeOpenIcon } from "@phosphor-icons/react/ssr";

import {
  SwipeAction,
  SwipeActions,
  SwipeActionsContent,
  SwipeActionsTray,
} from "@/components/pro/data/swipe-actions";

export function MailRow({ onArchive }: { onArchive: () => void }) {
  return (
    <SwipeActions onDismiss={onArchive}>
      <SwipeActionsContent className="px-4 py-3">Launch notes from Ana</SwipeActionsContent>
      <SwipeActionsTray side="leading">
        <SwipeAction tone="info" primary>
          <EnvelopeOpenIcon aria-hidden />
          Read
        </SwipeAction>
      </SwipeActionsTray>
      <SwipeActionsTray side="trailing">
        <SwipeAction tone="primary" primary dismiss>
          <ArchiveIcon aria-hidden />
          Archive
        </SwipeAction>
      </SwipeActionsTray>
    </SwipeActions>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/swipe-actions
```

It adds 30 registry items: 28 files, 5804 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@xstate/react`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Swipe to Confirm](https://gelatinui.com/components/swipe-to-confirm.md)
- [Swipe Deck](https://gelatinui.com/components/swipe-deck.md)
- [Context Menu](https://gelatinui.com/components/context-menu.md)
- [Item](https://gelatinui.com/components/item.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves to the actions of a row. Focus on an action opens its tray. |
| Enter, Space | Runs the focused action. |
| Esc | Closes the open tray and puts the focus back on the row. |

## Accessibility

Each action is a real button with its label, so the keyboard and screen readers reach it with no swipe.

A touch that starts 20px or less from the start edge of the screen is left to the browser, so the iOS swipe back still works.

A disabled row takes its actions out of the Tab order.

## Motion

| Part | Motion |
| --- | --- |
| Release | sheet · 300ms · ease-panel (0.2, 0.4, 0.2, 1) · the row settles at the nearest stop, with the speed of the fling |
| Commit | indicator · 200ms · ease-panel · the primary action grows over its tray past the commit point |
| Dismiss | panel · 260ms · ease-panel · the row slides out, then its height closes |
