Skip to content

Swipe row

iOS trailing swipe actions for a list row on touch screens.

The gesture exists only where the main pointer is coarse (a touch screen): a swipe to the left uncovers the actions, a tap elsewhere or a scroll covers them again, and a swipe across more than 60% of the row runs the last action. With a mouse or trackpad SwipeRow draws its children and nothing else, so the row has to offer the same actions itself, as buttons or in a menu. To try the example, open this page on a phone or turn on touch emulation. Give the row its background through className: the sliding content paints over the actions with it.

Trailing actions

  • Release 4.2.0 is ready to ship

    All 214 checks passed

  • INV-1040 is overdue

    It was due on 15 November

  • You were added to Atlas redesign

    As a reviewer

Installation

npx shadcn@latest add @khaeli/swipe-row

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items

Keyboard

Tab
On a touch screen with a keyboard: moves to each action in turn. Focus on an action slides the row open to show it, and leaving the last one closes the row.
EnterSpace
Run the focused action and close the row.

Accessible name

  • Each action is a button named by its label; the icon is all that shows. Put the row in the label (Archive INV-1040 is overdue), since every row has the same actions.
  • The actions differ by icon as well as colour: primary, neutral and destructive are never the only cue.
  • With a mouse, a trackpad or a keyboard on a desktop there are no swipe actions to reach. The buttons the row offers in their place need the same names.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/swipe-row.json