ListRow
BasicLayout
<co-list-row>ListRow is the 56px tappable row used for lists on phone and portal screens.
import { ListRow } from 'health-components';
Examples
Showcase
As Link
Static
Usage
<ListRow leading={<Avatar name="Henna West" size="sm" />} title="Henna West" meta="9:20 AM . Follow-Up" onClick={open} />
When to use
- Lists of patients, messages, settings on phones.
When not to use
- Desktop tables: DataTable.
Variants and states
| Variant | What it is |
|---|---|
| static / button | onClick makes it a button with a chevron. |
| leading / trailing | Avatar, badge. |
Accessibility
- Whole row is one button.
Do and don't
- Do: Two lines max.
- Don't: Nested buttons inside a button row.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title * | string | — | Main line |
meta | string | none | Second line |
leading | ReactNode | none | Before the text (Avatar, Icon) |
trailing | ReactNode | none | After the text (StatusTag, time); must not be interactive when the row is |
onClick | (event: MouseEvent<HTMLElement>) => void | none | Makes the row a button with a chevron |
href | string | none | Makes the row a link with a chevron |
target | AnchorHTMLAttributes<HTMLAnchorElement>['target'] | — | Link target when `href` is set |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-list-row>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-list-row title="…" meta="…" [target]="target" (co-click)="onClick($event.detail)"></co-list-row>
| Kind | Name | Description |
|---|---|---|
| attribute | title | Main line |
| attribute | meta | Second line; default none |
| attribute | href | Makes the row a link with a chevron; default none |
| property / JSON attribute | target | Link target when `href` is set |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-click | Makes the row a button with a chevron; default none (React: onClick) |
| slot | leading | Before the text (Avatar, Icon); default none Plain text also works as the `leading` attribute. |
| slot | trailing | After the text (StatusTag, time); must not be interactive when the row is; default none Plain text also works as the `trailing` attribute. |