Item
A list row with media, title, description and actions.
Variants
Default
No border and no fill: a row in a list.
Outline
A hairline border: a row that stands alone.
Muted
A quiet fill: a row that is set apart.
import { Item, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item"
const variants = [
{ variant: "default", title: "Default", description: "No border and no fill: a row in a list." },
{ variant: "outline", title: "Outline", description: "A hairline border: a row that stands alone." },
{ variant: "muted", title: "Muted", description: "A quiet fill: a row that is set apart." },
] as const
export default function ItemVariants() {
return (
<div className="flex w-full max-w-sm flex-col gap-3">
{variants.map(({ variant, title, description }) => (
<Item key={variant} variant={variant}>
<ItemContent>
<ItemTitle>{title}</ItemTitle>
<ItemDescription>{description}</ItemDescription>
</ItemContent>
</Item>
))}
</div>
)
}
Sizes
Default
Small
import { FolderIcon } from "@keyline-icons/react"
import { Item, ItemContent, ItemMedia, ItemTitle } from "@/components/ui/item"
const sizes = [
{ size: "default", title: "Default" },
{ size: "sm", title: "Small" },
{ size: "xs", title: "Extra small" },
] as const
export default function ItemSizes() {
return (
<div className="flex w-full max-w-sm flex-col gap-3">
{sizes.map(({ size, title }) => (
<Item key={size} size={size} variant="outline">
<ItemMedia variant="icon">
<FolderIcon />
</ItemMedia>
<ItemContent>
<ItemTitle>{title}</ItemTitle>
</ItemContent>
</Item>
))}
</div>
)
}
With media and actions
Invoice INV-0412
Due on 30 November. 1,240.00 for design and development.
Website refresh
Fourteen of twenty tasks are done.
import { ReceiptIcon } from "@keyline-icons/react"
import { Button } from "@/components/ui/button"
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"
const cover = `data:image/svg+xml,${encodeURIComponent(
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<rect width="32" height="32" fill="#5b45f5"/>
<path d="M0 24 10 16 18 20 32 8V32H0Z" fill="#fff" fill-opacity=".3"/>
</svg>`
)}`
export default function ItemWithMediaAndActions() {
return (
<div className="flex w-full max-w-md flex-col gap-3">
<Item variant="outline">
<ItemMedia variant="icon">
<ReceiptIcon />
</ItemMedia>
<ItemContent>
<ItemTitle>Invoice INV-0412</ItemTitle>
<ItemDescription>Due on 30 November. 1,240.00 for design and development.</ItemDescription>
</ItemContent>
<ItemActions>
<Button variant="outline">Send reminder</Button>
</ItemActions>
</Item>
<Item variant="outline">
<ItemMedia variant="image">
<img src={cover} alt="" />
</ItemMedia>
<ItemContent>
<ItemTitle>Website refresh</ItemTitle>
<ItemDescription>Fourteen of twenty tasks are done.</ItemDescription>
</ItemContent>
<ItemActions>
<Button variant="outline">Open</Button>
</ItemActions>
</Item>
</div>
)
}
As a link
import { ChevronRightIcon, RocketIcon } from "@keyline-icons/react"
import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "@/components/ui/item"
export default function ItemAsALink() {
return (
<Item variant="outline" className="max-w-sm" render={<a href="#release-4-2" />}>
<ItemMedia variant="icon">
<RocketIcon />
</ItemMedia>
<ItemContent>
<ItemTitle>Release 4.2</ItemTitle>
<ItemDescription>Fourteen changes, shipped on Tuesday.</ItemDescription>
</ItemContent>
<ItemActions>
<ChevronRightIcon className="size-4 text-muted-foreground" />
</ItemActions>
</Item>
)
}
Group
Export invoices as PDF
Billing
Done
Remember the sort order of task lists
Tasks
In review
Open the project switcher faster
Navigation
In progress
import { Badge } from "@/components/ui/badge"
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemSeparator, ItemTitle } from "@/components/ui/item"
const tasks = [
{ title: "Export invoices as PDF", owner: "Billing", status: "Done", tone: "positive" },
{ title: "Remember the sort order of task lists", owner: "Tasks", status: "In review", tone: "warning" },
{ title: "Open the project switcher faster", owner: "Navigation", status: "In progress", tone: "info" },
] as const
export default function ItemGroupExample() {
return (
<ItemGroup role="list" aria-label="Tasks in release 4.2" className="max-w-md gap-0">
{tasks.map(({ title, owner, status, tone }, index) => (
<div key={title} role="listitem">
{index > 0 ? <ItemSeparator className="my-0" /> : null}
<Item size="sm">
<ItemContent>
<ItemTitle>{title}</ItemTitle>
<ItemDescription>{owner}</ItemDescription>
</ItemContent>
<ItemActions>
<Badge variant={tone}>{status}</Badge>
</ItemActions>
</Item>
</div>
))}
</ItemGroup>
)
}
Header and footer
Release 4.2Shipped
Export invoices as PDF
Every invoice has a Download PDF action, and a month can be exported at once.
Billing12 November
import { Badge } from "@/components/ui/badge"
import { Item, ItemContent, ItemDescription, ItemFooter, ItemHeader, ItemTitle } from "@/components/ui/item"
export default function ItemHeaderAndFooter() {
return (
<Item variant="outline" className="max-w-sm">
<ItemHeader>
<span className="text-muted-foreground">Release 4.2</span>
<Badge variant="positive">Shipped</Badge>
</ItemHeader>
<ItemContent>
<ItemTitle>Export invoices as PDF</ItemTitle>
<ItemDescription>Every invoice has a Download PDF action, and a month can be exported at once.</ItemDescription>
</ItemContent>
<ItemFooter>
<span className="text-muted-foreground">Billing</span>
<span className="text-muted-foreground tabular-nums">12 November</span>
</ItemFooter>
</Item>
)
}
Installation
npx shadcn@latest add @khaeli/itembunx --bun shadcn@latest add @khaeli/itemInstall @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.
Installs with
- Registry items
- npm packages
- @base-ui/react ^1.7.0
- class-variance-authority ^0.7.1
Keyboard
Tab- Moves to an item rendered as a link, and to the buttons in
ItemActions. A plain item takes no focus. Enter- Follows an item rendered as a link.
Accessible name
- An item rendered as a link with
renderis named by everything inside it: keep the title first and the description short. ItemGroupis a plaindiv. For a list, passrole="list", wrap each row in an element withrole="listitem"and keepItemSeparatorinside the wrapper.- Icons and images in
ItemMediaare decoration beside a title: give an imagealt="".
Registry JSON
The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/item.json