Components / Data display
ListItem
Row in a List: a title and description, with optional leading and trailing content. With href or onClick it's a link or button.
import { ListItem } from "@stylhero/ui";
Example
Code
import { List, ListItem, CheckCircleIcon } from "@stylhero/ui";
function ListItemExample() {
return (
<List>
<ListItem title="Link row" description="Has href" href="#props" selected />
<ListItem title="Button row" description="Has onClick" onClick={() => {}} trailing={<CheckCircleIcon />} />
</List>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title required |
ReactNode |
- | |
description |
ReactNode |
- | |
disabled |
boolean |
- | |
href |
string |
- | Makes the whole row a link. |
leading |
ReactNode |
- | Left side: an Avatar, icon or Checkbox. |
onClick |
() => void |
- | |
selected |
boolean |
- | Highlights the row (e.g. the open conversation). |
trailing |
ReactNode |
- | Right side: a Badge, value or IconButton. |
Also takes every <li> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.
Keyboard
| Key | Does |
|---|---|
| Enter / Space | Activates it when it has href or onClick |
Accessibility
- With
hrefit's a link (aria-currentwhenselected); withonClicka button (aria-pressed).
Generated from src/components/List.tsx. Something wrong or missing? Open an issue.