Swipe List

View as Markdown

Rows a phone user swipes to act on, such as archive or mark read, with the same actions as buttons.

  • Unread: Priya RamanPricing page copy is ready for review
    9:41
  • Unread: BillingYour November invoice is $1,240.00
    8:02
  • Kenji WatanabeRe: offline mode, sync conflicts
    Yesterday
  • StatusResolved: elevated API errors in eu-west-1
    Mon
  • Ada OkaforQ1 planning doc, comments welcome
    Sun

Swipe a row on a phone, or hover it for its buttons.

When to use

Rows a phone user swipes to act on, such as archive or mark read, with the same actions as buttons. Use Record List instead when people use a mouse and keyboard more than a phone.

Usage

import { SwipeList } from "./ui/uicontext/components/SwipeList.ts"
const Message = UiSchema.TaggedEnum({ Deleted: { id: Schema.String } })export const Tasks = (h: Html.H<typeof Message.Type>, tasks: ReadonlyArray<{ readonly id: string; readonly title: string }>) =>	SwipeList(h, {		key: "tasks",		props: { label: "Tasks", items: tasks, left: { id: "delete", label: "Delete", tone: "danger", removes: true } },		onEmit: { Acted: ({ id }) => Message.Deleted({ id }) },	})

Examples

Resolve or snooze

An action with removes slides the row away for good; one without slides back once the app updates the row.

  • Unread: p95 latency over 400 mscheckout-api · eu-west-1
    2m
  • Unread: Disk 91% fullpostgres-primary
    14m
  • Queue backlog over 10,000email-worker
    1h

API reference

Props

SwipeList props
NameTypeDescription
labelrequiredstring—
itemsrequiredSwipeItem[]—
leftSwipeActionWhat a swipe to the left does
rightSwipeActionWhat a swipe to the right does
emptystringWhat the list says with no rows

Events

SwipeList events
EventPayloadDescription
Acted{ id: string; action: string }—

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/swipe-list

Source