Skip to content
Data displayGenerated from the public API

SortableAnnouncer

Reorder with pointer or keyboard, announcing every move.

@luc/ui

Examples

Default

The list is controlled: it reports the complete new order and the caller owns it.

  • IntroductionFour slides
  • The datasetSix slides
  • MethodFive slides
  • ResultsNine slides
  • Next stepsTwo slides

Usage

import { SortableAnnouncer } from "@luc/ui";
const [order, setOrder] = useState(items.map((item) => item.id));

<SortableList
  label="Talk outline"
  items={order.map((id) => items.find((item) => item.id === id)!)}
  onReorder={setOrder}
/>

Package setup — peer requirements, the stylesheet and the provider — is on installation.

API

Read from the published TypeScript API, so a prop that is not listed here does not exist and a default that is listed is the one the compiler sees.

Exported symbols
ExportKindSignature
SortableAnnouncer1 documented props({ message }: { message: string; }) => import("@types/react").JSX.Element
SortableList4 documented props({ items, onReorder, label, disabled, className, ...props }: SortableListProps) => import("@types/react").JSX.Element

SortableAnnouncer props

Type: { message: string; }

Values the compiler reads from the declaration.

SortableAnnouncer props
PropTypeDefaultNotes
messagestring—

SortableList props

Type: SortableListProps

Values the compiler reads from the declaration.

SortableList props
PropTypeDefaultNotes
disabled?boolean | undefined—
itemsreadonly SortableItem[]—
label?string | undefined—
onReorder(ids: string[]) => void—The complete id order after the move — never a delta.

Guidelines

Do

  • Keep the order in the caller: `onReorder` reports the complete new order, which is what a server needs to persist.
  • Write a `message` that says what moving the row did; it is announced, and “Moved” alone does not.

Don't

  • Use drag-and-drop as the only way to reorder; the keyboard path is part of the component and hiding it makes the list inaccessible.

Accessibility

Each row is a focusable item with a keyboard move, and `SortableAnnouncer` reports the new position. `disabled` keeps the list readable while removing the reorder controls.

Family

Data display

Dense, sortable, scannable: the surfaces a real product reads numbers from.

17 documented entries in this family. Open the family index

Luc UI v1.0SortableAnnouncerdark theme