Skip to the content
BooleanPress UI

Misc

Item

A flexible row with media, a title, a description and actions, for settings, lists and cards.

Import

import { Item, ItemMedia, ItemContent, ItemActions, ItemGroup, ItemSeparator, ItemTitle, ItemDescription, ItemHeader, ItemFooter } from "@booleanpress/ui/item"

Usage

An item lays out a row: optional media, a content block with a title and a description, and actions. Header and footer parts take a full-width line above and below.

import { Item, ItemContent, ItemDescription, ItemTitle } from "@booleanpress/ui/item"

export function Mailer() {
  return (
    <Item variant="outline">
      <ItemContent>
        <ItemTitle>Primary mailer</ItemTitle>
        <ItemDescription>Sends through smtp.example.com on port 587.</ItemDescription>
      </ItemContent>
    </Item>
  )
}

variant is default (no frame), outline (a border) or muted (a tinted fill); size is default or sm. ItemMedia takes variant="icon" (a small bordered tile) or "image" (a 40 px picture). ItemGroup stacks items and ItemSeparator draws the line between them.

Pass asChild and a link to make the whole item a link: it keeps the link's role, gets a hover fill and the focus ring. Do not put a second link or button inside such an item.

Examples

Basic

A title and a description in an outlined item.

Variants

default, outline and muted.

With media and actions

An icon tile, a title with a badge, and a button.

Group

Items in a group with separators between them.

asChild makes the whole row one link.

Accessibility

Semantics
Plain divs (and a p for the description), with no roles. ItemGroup has no role="list": stock adds it, which would require every child to be role="listitem", and Item is not one. For a real list, put the items in a ul and li yourself with asChild.
Labels
The title is the visible name. A link made with asChild is named by its content, so keep title and description short.
Focus
An item is not focusable unless it is a link or contains a control. The focus ring shows on keyboard focus.
Known limits
  • ItemDescription keeps two lines (line-clamp-2) and cuts the rest with an ellipsis, so the full text is not available to sighted users: keep descriptions short.
  • Without a list role, a screen reader does not announce how many items a group has.

Keyboard

Keyboard
KeyBehaviour

API

Item

Renders a div and passes it every other prop.

Item props
PropTypeDefaultDescription
asChildbooleanfalseRender the child element instead, usually a link, with the item's classes merged onto it.

ItemMedia

Renders a div and passes it every other prop.

ItemContent

Renders a div and passes it every other prop.

ItemActions

Renders a div and passes it every other prop.

ItemGroup

Renders a div and passes it every other prop.

ItemSeparator

ItemSeparator props
PropTypeDefaultDescription
asChildboolean
decorativebooleanWhether or not the component is purely decorative. When true, accessibility-related attributes are updated so that that the rendered element is removed from the accessibility tree.
orientation"horizontal" | "vertical"verticalEither vertical or horizontal. Defaults to horizontal.

ItemTitle

Renders a div and passes it every other prop.

ItemDescription

Renders a p and passes it every other prop.

ItemHeader

Renders a div and passes it every other prop.

ItemFooter

Renders a div and passes it every other prop.

Every part takes className, merged with its defaults by cn(), and ref, which reaches the element it renders.

Data attributes: data-slot="item" (Item), data-slot="item-media" (ItemMedia), data-slot="item-content" (ItemContent), data-slot="item-actions" (ItemActions), data-slot="item-group" (ItemGroup), data-slot="item-separator" (ItemSeparator), data-slot="item-title" (ItemTitle), data-slot="item-description" (ItemDescription), data-slot="item-header" (ItemHeader), data-slot="item-footer" (ItemFooter), and data-variant, data-size.

Theming

outline uses --border, muted a 50 % --muted fill, and a link item a 50 % --accent fill on hover.

The tokens its classes read. Change their values in your theme, and it follows.

Theme tokens
TokenUsed for
--accentbackground
--borderborder
--mutedbackground
--muted-foregroundtext
--primarytext
--ringborder, focus ring