Skip to content
Fleetline

Swipe actions

Usage

Use swipe actions on the mechanics' tablet and phone lists, where a row's two or three most frequent actions save a trip into the work order: mark it done, reassign it, delete a duplicate.

Content: one or two words per action, a verb ("Reassign", "Delete"). The destructive action says what it does in the menu ("Delete work order").

Anatomy

  1. Row — <li class="swipe-row"> with --_lead and --_trail action counts
  2. Track — .swipe-row__track, the horizontal scroll-snap container
  3. Leading actions — .swipe-row__actions--leading, inert until revealed
  4. Content — .swipe-row__content: link (stretched over the row), secondary text and the More actions menu button
  5. Trailing actions — .swipe-row__actions--trailing, edge action last; its color fills the full-swipe zone

Examples

Revealed and full-swipe states are frozen with docs-only classes; the first demo is live on touch screens.

Swipe actions

  • WO-4182 Brake inspectionVan KX-219 · Northside Depot
  • WO-4190 Tire rotationTruck TR-07 · Harbor Road
  • WO-4197 Coolant leakVan KX-224 · Eastgate

At rest only the content shows. On a touch screen swipe a row left for Reassign and Delete, right for Mark done; with a mouse or keyboard use the More actions button.

Swiped toward the inline start: trailing actions are revealed and focusable. Tapping the content closes the row.

Swiped toward the inline end: the leading action (Mark done) is revealed.

Swiped past half the trailing zone: the edge action (Delete) covers the row and runs on release. The row is removed with an Undo toast.

Keyboard focus on the row's link: the ring sits inside the row so the next row doesn't cover it.

The same actions in the row's menu button: the required non-swipe path, and the only one with a mouse.

<ul class="list-group swipe-list" role="list" aria-label="Work orders">
  <li class="swipe-row" style="--_lead: 1; --_trail: 2">
    <div class="swipe-row__track">
      <div class="swipe-row__actions swipe-row__actions--leading" inert>
        <button type="button" class="swipe-row__action swipe-row__action--primary">Mark done</button>
      </div>
      <div class="swipe-row__content">
        <div class="swipe-row__main"><a class="swipe-row__link" href="/work-orders/4182">WO-4182 Brake inspection</a>
          <span class="swipe-row__secondary">Van KX-219 · Northside Depot</span></div>
        <button type="button" class="icon-btn swipe-row__menu" aria-haspopup="menu" aria-controls="wo-4182-menu"
                commandfor="wo-4182-menu" command="toggle-popover" aria-label="More actions for WO-4182 Brake inspection">…</button>
        <div class="menu" id="wo-4182-menu" popover role="menu">Mark done · Reassign · Delete work order</div>
      </div>
      <div class="swipe-row__actions swipe-row__actions--trailing" inert>
        <button type="button" class="swipe-row__action">Reassign</button>
        <button type="button" class="swipe-row__action swipe-row__action--danger">Delete</button>
      </div>
    </div>
  </li>
</ul>
<script type="module">import { init } from "./js/swipe-actions.js"; init();</script>

API

HookValuesPurpose
.swipe-rowblockOne row; --_lead / --_trail = number of leading / trailing actions
.swipe-row__action--primary | --dangermodifierAction color; the trailing edge action (last) sets the full-swipe color
.swipe-listmodifier on .list-groupClips revealed actions to the list's rounded frame
js/swipe-actions.js init(root)moduleRest position, inert sync, one open row, tap-to-close, full swipe (.is-full)
.is-revealed-trailing | -leading | .is-full-swipe | .is-focus-visibledocs-only classFreeze a state for documentation and snapshots

Do and don't

Swipe for Reassign and Delete, and the same three actions in the row's menu.

Do mirror every swipe action in the menu, so mouse, keyboard and switch users get them too.

Delete only by swiping, with no Undo.

Don't make a gesture the only path, or let a full swipe destroy data without Undo.

Accessibility

Keyboard interaction
KeyBehavior
TabRow link, then the More actions button. Hidden swipe actions are inert and skipped
Enter / Space on More actionsOpens the menu with the same actions (APG menu button)

Tokens

Custom propertyPurpose
--size-swipe-actionWidth of each action (mobile scope token, same on native)
--size-touch-targetMinimum row and action height
--color-action-{primary|secondary|danger}-{bg|fg}Action colors
--color-elevation-surface-raisedRow content surface
--color-border-subtleSeparator between rows
--focus-ring-width, --focus-ring-colorInset focus ring