组件 · 数据展示
ListRow
The row for the people and agents on a detail page, settings and shortcuts — a leading block, a title and a preview, the time and a badge.
import { ListRow } from "@botiverse/raft-ui";A ListRow is one row of a list: a person, an agent, a setting or a shortcut into another page. The whole row is the target. Use it for the agents and people on a detail or profile page, and for settings. Raft Chat's phone lists of places (Home, Members, the Settings list) use the sidebar row instead (Choosing a component).
When to use
| Situation | Use |
|---|---|
| Channels, direct messages and members in a phone list | The sidebar row (Sidebar), as in Raft Chat |
| Channels and people among search results | ListRow, through the search result row (Search) |
| Agents and people on a profile or detail page, such as a computer's details | ListRow in a ListRowGroup (Identity and presence) |
| A row of the desktop sidebar | The sidebar row (Sidebar) |
| Activity and notifications | InboxItem |
| A task | TaskCard |
Anatomy
ListRow: the row. Abuttonby default; render a link for a row that goes somewhere.- Leading block: an Avatar, a channel tile (IconTile) or a 20px
ListRowIcon. Optional. ListRowBody: the text column. Required.ListRowTop:ListRowTitle, then the time inListRowMeta.ListRowBottom: the preview inListRowDescription, then at most one badge.
- Trailing: a setting's
ListRowValueandListRowChevron, or a Switch. Optional. ListRowGroup: an inset group that wraps rows in a card. Optional.
In a plain row with a description, both ends center on the title's first line instead of the middle of the title and description: the leading icon, avatar or tile, and the trailing value, chevron, switch, checkbox or radio. Each keeps its size, so the row still accounts for a 30px switch. With a title alone, the title is the whole block and everything stays centered at the row's height, 54px on a phone with a switch (Alignment).
Variants
| Variant | Use for |
|---|---|
variant="default" | A conversation, a person or an agent: leading block, title, preview, time and badge. At least 64px tall |
variant="plain" | A setting: an optional icon, a title (and its consequence), then the current value and a chevron, or a switch. 48px tall with one line of text |
variant="entry" | A shortcut into another page at the top of a list (Saved on phone Home): a 20px icon and a name, with a badge or a gray count on the right. 48px tall |
States
tone says what the place is to the person. The shared states are in States.
| State | Use for |
|---|---|
tone="unread" | Something waits here: bold title, the preview in foreground, and a pink count in ListRowBottom. When someone mentions the person, the yellow @ marker replaces the count (Badge) |
tone="muted" | The person muted it: the title in foreground-muted. Add a bell-off icon after the title, and show unread as a gray count in ListRowMeta instead of a pink badge |
tone="away" | The person hasn't joined yet: title and preview in foreground-hint |
selected | The item open beside the list: an info-soft wash, and no hover |
disabled | Every part in foreground-disabled; no tone, no unread or muted marks, no hover or press, and the fill doesn't change |
Behavior
- Divide rows with
line-hairline. In the default variant the line starts where the text starts; in a settings list it starts at the row's edge (16px); entry rows have no lines between them, because they are a set of buttons, not a list of content. - The whole row is the target: hover lays the subtle tier,
fill-subtle, over all of it and press the medium tier (Hover and press). While a menu it opened is up (data-popup-open: a context menu, or press and hold on a phone), it laysfill-subtletoo, hovered or not; a selected row keeps its selection. - A row whose only targets are its own controls (a setting with a switch) takes
interactive={false}: it renders a plain element with no hover or press. See States.
Content
- Start a preview with who spoke: "Wug: Release notes are drafted."
- Show at most one badge in a row.
- Set the time and counts in Space Mono;
ListRowMetadoes this. - Write a setting's consequence in
ListRowDescriptionwithwrap, so it isn't cut off.
Group headings
A group of rows can have a heading above it, such as Channels.
- Write it in sentence case, in
text-footnoteat weight 700 andforeground-hint(Typography). - Make the heading a button with
aria-expandedwhen the group can collapse, and show the number of rows when it is collapsed. - Put the group's action on the right as an ink text button that underlines on hover (TextLink): Browse.
raft-ui has no exported heading part for these lists yet.
Accessibility
ListRowuses Base UI'suseRenderand renders a nativebutton(or the link you pass withrender), so the row is reached with Tab and activated with Enter or Space. Withinteractive={false}it is adivand only its controls are focusable.- The accessible name is the row's text. Add an accessible name to a badge that is only a number or an icon:
aria-label="3 unread",aria-label="Mentions you". selectedis visual only. Setaria-currentoraria-selectedon the row yourself.- Label a switch in a settings row with the row's title (
aria-labelledby). ListRowIconandListRowChevronare hidden from assistive technology.
Rules
- Don't add an ink border or a shadow to a row or a group: a list is content, and an ink border means a control (Color).
API
ListRow
| Prop | 类型 | 默认值 |
|---|---|---|
| `false` renders a display-only row: a `div` with no hover or press, for a row whose controls (a switch, a button) are its only targets. | boolean | true |
| The item open beside the list: the row takes the cyan wash and stops reacting to hover. Say why it is selected with `aria-current` or `aria-selected` yourself. | boolean | false |
| Something waits for you here (bold title, ink preview), the place is muted (ink-2 title), or you are not in it yet (ink-3 title and preview). A disabled row ignores it: everything is ink-disabled. | RowTone | "default" |
| "default" | "plain" | "entry" | "default" | |
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
ListRowBody, ListRowBottom, ListRowChevron
| Prop | 类型 | 默认值 |
|---|---|---|
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
ListRowDescription
| Prop | 类型 | 默认值 |
|---|---|---|
| Let the text run onto more lines instead of truncating: a setting's consequence. | boolean | false |
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
ListRowGroup, ListRowIcon, ListRowMeta, ListRowTitle, ListRowTop, ListRowValue
| Prop | 类型 | 默认值 |
|---|---|---|
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
相关组件
改动
- 0.6.1 · Added
ListRow, the Design System list row (rf-row):ListRowGroup(the inset card),ListRowIcon,ListRowBody/ListRowTop/ListRowBottom,ListRowTitle,ListRowDescription,ListRowMeta,ListRowValue,ListRowChevron. Variantsdefault(64, hairline from the text),plain(setting row, 48) andentry(48, no hairlines);tone(unread/muted/away),selected(cyan-soft),disabled, andinteractive={false}for a display-only row.