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>As a link
tsx
<Item as={Link} to="/margo-ui/button" active={isCurrent} aria-current={isCurrent ? "page" : undefined}>
<Item.Label>Button</Item.Label>
<Item.Icon />
</Item>Reference
| prop | type | default | |
|---|---|---|---|
as? | ElementType | "button" | the element or component to render |
active? | boolean | false | primary border; visual only |
disabled? | boolean | false | native disabled on a button, aria-disabled on anything else; dimmed |
clickable? | boolean | true | false 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 |
…rest | props of as | — | typed against the chosen element |
Item.Label
| prop | type | default | |
|---|---|---|---|
children | ReactNode | — | the text; truncated on one line |
className? | string | — | added after the part's own class: what you set wins |
Item.Icon
| prop | type | default | |
|---|---|---|---|
children? | ReactNode | <MdChevronRight /> | the icon; a chevron if you pass none |
className? | string | — | added after the part's own class: what you set wins |