Item
A row of media, title, description and actions.
Your card ending 4242 is now the default.
Installation
npx shadcn@latest add @oakoss/itemUsage
import {
Item,
ItemContent,
ItemDescription,
ItemTitle,
} from '#/components/ui/data/item';
<Item variant="outline">
<ItemContent>
<ItemTitle>Billing updated</ItemTitle>
<ItemDescription>Your card is now the default.</ItemDescription>
</ItemContent>
</Item>;Examples
Group
ItemGroup makes its Items a list. Put the Items directly inside it;
ItemSeparator can sit between them.
ada@example.com
grace@example.com
Link
href on Item turns its ItemTitle into a link stretched over the whole
row. Buttons in ItemActions and links in ItemDescription stay pressable
above it. A linked Item needs an ItemTitle, which carries the link.
Triggers an action or event.
Accessibility
A linked Item's title is a React Aria Link, so it follows your router when
the app sets up React Aria's
RouterProvider. To use your
router's own link component, pass render to Item; it reaches the title
link. Don't wrap Item in a router's createLink: the row is a div, not
the link.
This component adds:
- Lists:
ItemGroupis alistwhose direct Items are its list items, andItemSeparatoris hidden from screen readers, since a list allows only list items. - Links: the row is never a link itself. The title is, so the link's name is the title alone, and buttons in the row aren't nested inside a link.
- Focus: keyboard focus on the title link outlines the whole row.
- Media:
ItemMediais decorative and hidden from screen readers unless you name it witharia-label, which makes it an image. - Titles:
ItemTitleis text by default; setlevelto make it a heading. A long title stays on one line. - Windows High Contrast: outline and muted Items keep their border, and the default look stays borderless, so a list doesn't become a stack of boxes.
| Key | Action |
|---|---|
Tab | Moves to the title link, then each action |
Enter | Follows the focused link |
React Aria adds no keys.
API
Item
A div, and accepts all its props.
Props
Prop
Type
Also accepts href, rel, target, routerOptions and render from React
Aria's Link, which go to the title
link.
Data attributes
| Attribute | Present when |
|---|---|
data-slot | Always item |
data-size | Always; md, sm or xs |
data-variant | Always; default, outline or muted |
ItemGroup
A div with the list role, and accepts all its props.
Data attributes
| Attribute | Present when |
|---|---|
data-slot | Always item-group |
ItemTitle
A div, or a heading with level. In a linked Item it holds a React Aria
Link, which takes the item-title
slot.
Props
Prop
Type
Data attributes
| Attribute | Present when |
|---|---|
data-slot | Always item-title |
data-hovered | On the link, while a pointer hovers the row |
data-focus-visible | On the link, while it has keyboard focus |
ItemMedia
A div, and accepts all its props.
Props
Prop
Type
Data attributes
| Attribute | Present when |
|---|---|
data-slot | Always item-media |
data-variant | Always; default, icon or image |
ItemContent, ItemDescription, ItemActions and ItemSeparator
A div, a p, a div and an hr, accepting all their props.
Data attributes
| Attribute | Present when |
|---|---|
data-slot | Always item-content, item-description, item-actions or item-separator |