Data display
Cell
A SimpleCell with list-editing modes: selectable (checkbox or radio), removable, and draggable reordering inside List.
import { Cell, List } from "datui";Playground
Cell title Subtitle
<Cell subtitle="Subtitle" selectionType="checkbox">Cell title</Cell>Examples
Selectable
The whole row is a label for a native checkbox or radio.
Removable
A trailing remove button, separate from the row's own action.
+1 555 0100
+1 555 0101
+1 555 0102
Draggable
Drag the handle, or focus it and use Space and the arrow keys. You reorder the data in onDragFinish.
Inbox
Starred
Sent
Drafts
Accessibility
- Inside
Listthe container hasrole="list"and every Cell is alistitem. mode="selectable"renders a<label>around a realinput type=checkbox(orradio), so clicking the row or pressing Space toggles it and the row text is its name.mode="removable"adds a separate button labelledremoveLabel("Remove"); it is not nested in the row's button and does not triggeronClick.- The drag handle is a button labelled
dragHandleLabel("Reorder") witharia-roledescription="sortable". Space or Enter lifts, arrow keys move, Space or Enter drops, Escape cancels. - Moves are announced through a live region;
ListacceptsannouncementsanddragInstructionsto localize them. disableddisables the row, the selection input, the remove button and the drag handle.
API
Cell
SimpleCell with list-editing modes: selectable (checkbox/radio), removable and draggable reorder. `ref`, `className` and `style` go to the outer row element.
| Prop | Type | Default | Description |
|---|---|---|---|
| activated | boolean | — | Keep the pressed look, e.g. for the active item of a list. |
| after | ReactNode | — | Trailing content, e.g. a switch, counter or button-free text. |
| as | ElementType<any, keyof IntrinsicElements> | — | Element to render. Defaults to `a` with `href`, `button` with `onClick`, otherwise `div`. |
| badgeAfterSubtitle | ReactNode | — | |
| badgeAfterTitle | ReactNode | — | |
| badgeBeforeSubtitle | ReactNode | — | |
| badgeBeforeTitle | ReactNode | — | |
| before | ReactNode | — | Leading content, e.g. an icon or avatar. |
| checked | boolean | — | |
| chevron | boolean | false | Show a trailing chevron for navigational rows. |
| chevronSize | "s" | "m" | "m" | |
| className | string | — | |
| defaultChecked | boolean | — | |
| disabled | boolean | — | |
| draggable | boolean | — | Show a reorder handle. Works for direct children of `List`; the consumer reorders data in `onDragFinish`. |
| dragHandleLabel | string | Reorder | |
| extraSubtitle | ReactNode | — | |
| hasActive | boolean | true | Background tint while pressed. |
| hasHover | boolean | true | Background tint on hover. |
| href | string | — | |
| indicator | ReactNode | — | Secondary value shown before `after`, e.g. the current setting. |
| mode | "selectable" | "removable" | — | `selectable` turns the row into a label with a checkbox or radio; `removable` adds a trailing remove button. |
| multiline | boolean | false | Wrap long text instead of truncating it. |
| name | string | — | Form field name of the selection input. |
| onCheckedChange | ((checked: boolean) => void) | — | |
| onDragFinish | ((move: { from: number; to: number; }) => void) | — | Called after a drop with the original and new index within the List. |
| onRemove | ((event: MouseEvent<HTMLButtonElement, MouseEvent>, rootEl: HTMLDivElement | null) => void) | — | `mode="removable"`: called with the click event and the Cell's root element. |
| overTitle | ReactNode | — | Small text above the title. |
| rel | string | — | |
| removeLabel | string | Remove | |
| selectionType | "checkbox" | "radio" | checkbox | Control used by `mode="selectable"`. Radios sharing a `name` form a single-choice group. |
| subtitle | ReactNode | — | |
| target | string | — | |
| type | "button" | "submit" | "reset" | — | |
| value | string | — | Form value of the selection input. |
List
Container for Cells (`role="list"`). Also hosts drag-and-drop reordering for `draggable` Cells, which must be its direct children.
| Prop | Type | Default | Description |
|---|---|---|---|
| announcements | ListAnnouncements | — | Screen reader announcements for drag reordering, for localization. Positions are 1-based; each function overrides the English default for that event. |
| className | string | — | |
| dragInstructions | string | To reorder, press Space or Enter on the handle, use the arrow keys to move, then Space or Enter to drop. Press Escape to cancel. | Instructions read when a drag handle is focused. |
| gap | number | 0 | Space between items in px. |