Item

A row in a list: a label and an optional icon. The sidebar of this site is made of them.

Usage

tsx
<Item onClick={select}>
  <Item.Label>Introduction</Item.Label>
  <Item.Icon />
</Item>

Icons and extra content

An icon before the label goes on the left. Anything else you mount sits in the row, and the icon stays on the right.

tsx
<Item>
  <Item.Icon>
    <MdChevronLeft />
  </Item.Icon>
  <Item.Label>back</Item.Label>
</Item>

<Item>
  <Item.Label>typescript</Item.Label>
  <Chip className="mx-2">4</Chip>
  <Item.Icon>
    <MdOpenInNew />
  </Item.Icon>
</Item>

States

tsx
<Item active>…</Item>
<Item clickable={false}>…</Item>
<Item disabled>…</Item>

Reference

proptypedefault
as?ElementType"button"the element or component to render
active?booleanfalseprimary border; visual only
disabled?booleanfalsenative disabled on a button, aria-disabled on anything else; dimmed
clickable?booleantruefalse makes it inert without changing its look
onClick?MouseEventHandler—not called while disabled
className?string—added after the component's own class: what you set wins
…restprops of as—typed against the chosen element

Item.Label

proptypedefault
childrenReactNode—the text; truncated on one line
className?string—added after the part's own class: what you set wins

Item.Icon

proptypedefault
children?ReactNode<MdChevronRight />the icon; a chevron if you pass none
className?string—added after the part's own class: what you set wins