oakoss/ui
Components

Item

A row of media, title, description and actions.

SourceReact Aria
Billing updated

Your card ending 4242 is now the default.

Installation

npx shadcn@latest add @oakoss/item

Usage

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 Lovelace

ada@example.com

Grace Hopper

grace@example.com

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: ItemGroup is a list whose direct Items are its list items, and ItemSeparator is 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: ItemMedia is decorative and hidden from screen readers unless you name it with aria-label, which makes it an image.
  • Titles: ItemTitle is text by default; set level to 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.
KeyAction
TabMoves to the title link, then each action
EnterFollows 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

AttributePresent when
data-slotAlways item
data-sizeAlways; md, sm or xs
data-variantAlways; default, outline or muted

ItemGroup

A div with the list role, and accepts all its props.

Data attributes

AttributePresent when
data-slotAlways 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

AttributePresent when
data-slotAlways item-title
data-hoveredOn the link, while a pointer hovers the row
data-focus-visibleOn the link, while it has keyboard focus

ItemMedia

A div, and accepts all its props.

Props

Prop

Type

Data attributes

AttributePresent when
data-slotAlways item-media
data-variantAlways; default, icon or image

ItemContent, ItemDescription, ItemActions and ItemSeparator

A div, a p, a div and an hr, accepting all their props.

Data attributes

AttributePresent when
data-slotAlways item-content, item-description, item-actions or item-separator