Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Mobile

Swipe action

A list row that reveals action buttons when swiped, such as delete or archive.

Selector: mui-swipe-action

Import
import { SwipeAction } from '@mushilu-san/ui/mobile';
PreviewCode

Loading example…

Overview

Swipe action wraps a list row. Dragging the row sideways reveals the actions, and actionTriggered emits the key of the chosen action. Each action sets a side, start or end, which flips in RTL.

Keyboard and screen reader users get the same actions as a button list, labelled "Row actions", so swiping is never the only way in.

When to use

  • Per-row shortcuts in a phone list, such as archive or delete.
  • Lists where the same two or three actions apply to every row.

When not to use

  • Actions that need a confirmation or explanation. Use a dialog. Use Alert dialog instead.
  • Actions users must discover on desktop. Show them in the row.

Guidelines

Do

  • Use colour and a text label on each action.
  • Put the most destructive action last.

Don't

  • Do not make a destructive action the only way to delete a row. Confirm it.

Accessibility

Roles and attributes

ElementRoleNotes
rowlistitemThe host is the list item, so put rows inside a list.
more actions buttonbuttonaria-expanded follows the reveal state.
action groupgroupLabelled "Row actions" with the same actions as buttons.

Keyboard

KeysAction
TabShiftTabMoves through the row and its action buttons.
EnterSpaceTriggers the focused action.
  • Put the rows inside a list, so each row is announced as a list item.

API

SwipeAction

Selector: mui-swipe-action

NameTypeDefaultDescription
actionsSwipeActionItem[][] Action descriptors.
NameTypeDescription
actionTriggeredstring Emits the key of the triggered action.

CSS parts

  • ::part(a11y-btn)
  • ::part(action)
  • ::part(container)
  • ::part(kbd-collapse)
  • ::part(kbd-trigger)
  • ::part(root)
  • ::part(track)

Tokens

  • --mui-color-danger
  • --mui-color-success
  • --mui-color-warning
  • --mui-color-primary
  • --mui-color-surface
  • --mui-touch-target