Installation
Section titled “Installation”- Package
@bigbang/ui- Import
import { ListItem } from '@bigbang/ui';- Source
- ListItem.tsx
- Storybook
- ListItem · Playground
ListItem is in the @bigbang/ui package. Installation and style files are the same as for Button; see the Button code tab.
import { ListItem } from '@bigbang/ui';
<ListItem.List divided aria-label="Settings"> <ListItem title="Settings" subtitle="Account and appearance" meta="Today" /> <ListItem title="Notifications" render={<a href="/notifications" />} /></ListItem.List>;The part prop types are exported too: ListItemLeadingProps, ListItemContentProps, ListItemTitleProps, ListItemSubtitleProps, ListItemMetaProps, ListItemTrailingProps, ListItemListProps.
title- Description
- The main text. Required unless you compose the parts yourself through
children. - Type
ReactNode
subtitle- Description
- A second, smaller line under the title.
- Type
ReactNode
meta- Description
- Short information at the inline end, such as a date or a count. It stays on one line.
- Type
ReactNode
leading- Description
- What comes first: an
Avatar, anIconor a thumbnail. Mark an Avatardecorativewhen the title already names it. - Type
ReactNode
trailing- Description
- What comes last. In a row made interactive with
renderit must not hold a link or a button; use a static row for that. - Type
ReactNode
size- Description
- Block padding of 8, 12 or 16 px (
sm,md,lg);lgalso sets a larger title. - Type
Size- Default
'md'
variant- Description
outlinedraws a 1 px border around the row andmutedgives it a tinted surface;defaulthas neither.- Type
'default' | 'outline' | 'muted'- Default
'default'
selected- Description
- Marks the current row: a selected surface and a bar at the inline start, plus
aria-current="true"on an interactive row. Use it for navigation, not for toggles. - Type
boolean- Default
false
disabled- Description
- Greys the row out. An interactive row also leaves the tab order and ignores clicks (
aria-disabled). - Type
boolean- Default
false
truncate- Description
- Keeps the title and subtitle on one line and cuts the overflow with an ellipsis. By default the title shows one line and the subtitle two, then an ellipsis.
- Type
boolean- Default
false
render- Description
- Makes the row one interactive target:
<a href="…" />,<button type="button" />or a router link. Without it the row is static. - Type
ReactElement | ComponentRenderFn<HTMLProps, {}>
className- Description
- For layout only: margins and grid placement. Do not use it to change colour or padding.
- Type
string
children- Description
- The row parts:
ListItem.Leading,ListItem.Content,ListItem.MetaandListItem.Trailing. When set,title,subtitle,meta,leadingandtrailingare not drawn. - Type
ReactNode
Native attributes (id, data-*) pass through to the root <li>. States such as aria-current and data-selected are set on the row.
| Part | Element | Props |
|---|---|---|
ListItem.List |
<ul> |
divided, animate, className and native ul attributes. Comes with role="list". |
ListItem.Leading |
<div> |
Native attributes. The start slot. |
ListItem.Content |
<div> |
Native attributes. Takes the free width; stacks the title and subtitle. |
ListItem.Title |
<span> |
Native attributes. truncate comes from the root. |
ListItem.Subtitle |
<span> |
Native attributes. |
ListItem.Meta |
<span> |
Native attributes. One line. |
ListItem.Trailing |
<div> |
Native attributes. The end slot. |
With children, title, subtitle, meta, leading and trailing are not drawn; you compose the parts.
Data attributes
Section titled “Data attributes”data-component="list-item",data-size,data-selected,data-disabled,data-interactive: on the root<li>.data-selectedanddata-disabledare also on the row.data-part:row,leading,content,title,subtitle,meta,trailing. The list carriesdata-component="list".
Router link
Section titled “Router link”import { ListItem } from '@bigbang/ui';import { Link } from 'react-router';
<ListItem title="Settings" selected render={<Link to="/settings" />} />;Separate action
Section titled “Separate action”<ListItem title="First item" trailing={ <Button size="sm" variant="tertiary"> Edit </Button> }/>