Item
elements man ui/templates/itemA row with media, a title, a description and actions, alone or in a list.
Exampleimport { Item, ItemGroup, ItemSeparator, ItemMedia, ItemContent, ItemTitle, ItemDescription, ItemActions, ItemHeader, ItemFooter, } from "@elements/ui/item"; import { Icon } from "@elements/ui/icon"; import { Button } from "@elements/ui/button"; <Item variant="outline"> <ItemMedia variant="icon"><Icon name="shield" /></ItemMedia> <ItemContent> <ItemTitle>Security alert</ItemTitle> <ItemDescription>New sign-in from an unknown device.</ItemDescription> </ItemContent> <ItemActions><Button size="sm">Review</Button></ItemActions> </Item> <Item href="/settings/profile" title="Your profile" description="Name, photo and email." />
A row that runs an action, such as picking an account, takes onclick and
renders as a <button>. The title, description and media wrap as they do
in any Item.
Example<ItemGroup label="Demo accounts"> <Item e:for={login of logins} variant="outline" title={login.name} description={login.email} onclick={() => signInAs(login)}> <Badge slot="media" variant="neutral">{login.role}</Badge> </Item> </ItemGroup>
When the title and ItemActions do not fit on one line, the actions move to
a line of their own at the inline end, so the title keeps whole words. The
content keeps at least --item-content-min (10rem) before the row wraps.
Parts
| Part | What it is |
|---|---|
ItemGroup |
.item-group, role=list. |
ItemSeparator |
.item-separator, a decorative rule. |
ItemMedia |
.item-media: an icon tile, a thumbnail, an avatar. |
ItemContent |
.item-content: title and description, takes the free width. |
ItemTitle |
.item-title. |
ItemDescription |
.item-description, two lines at most. |
ItemActions |
.item-actions: trailing controls. |
ItemHeader |
.item-header: a full line above. |
ItemFooter |
.item-footer: a full line below. |
Attributes
Item
| Attribute | Type | Default | Description |
|---|---|---|---|
title |
string |
"" |
Renders a title in ItemContent. |
description |
string |
"" |
Renders a description in ItemContent. |
variant |
"default" | "outline" | "muted" |
"default" |
Transparent, bordered, or filled. |
size |
"md" | "sm" | "xs" |
"md" |
Padding and gap. |
href |
string |
"" |
Makes the whole row a link. |
onclick |
(e: MouseEvent) => void |
undefined |
Makes the whole row a <button> that calls it. A link or button row holds no other controls, so leave out ItemActions. |
disabled |
boolean |
false |
Disables a button row. |
class |
string |
"" |
Extra classes. |
attrs |
Record<string, string | number | boolean | undefined> |
{} |
Other attributes for the row, link or button: target, rel, aria-*. |
ItemGroup
| Attribute | Type | Default | Description |
|---|---|---|---|
label |
string |
"" |
Names the list. |
gap |
boolean |
false |
Space between items. |
ItemMedia
| Attribute | Type | Default | Description |
|---|---|---|---|
variant |
"default" | "icon" | "image" | "avatar" |
"default" |
icon is a bordered tile; image a square thumbnail. |
every part
| Attribute | Type | Default | Description |
|---|---|---|---|
class |
string |
"" |
Extra classes. |
Slots
| Slot | Part | Content |
|---|---|---|
media |
Item |
Media for the title shortcut. |
default |
Item |
Parts in any order. |
default |
each part |
The part's content. |
Keyboard
| Keys | Action |
|---|---|
Tab |
Focuses a link or button item, then the controls inside items. |
Enter |
Follows a link item, or presses a button item. |
Space |
Presses a button item. |
Data attributes
| Attribute | Values | On |
|---|---|---|
data-variant |
"default" | "outline" | "muted" |
Item |
data-size |
"md" | "sm" | "xs" |
Item |
data-variant |
"default" | "icon" | "image" | "avatar" |
ItemMedia |
Accessibility
- ItemGroup is a list and each Item in it a listitem; a link or button item keeps its role inside a listitem wrapper.
- Link and button items show the theme focus ring.
- Icon media is hidden from screen readers; the title says what the row is.
See also
- Icon (opens in a new tab): An inline stroke icon from the set the templates draw their own controls with, sized in pixels and colored by the text around it.
- Button (opens in a new tab): A button or a link that looks like one, in six variants and four sizes.
- Badge (opens in a new tab): A small label for a status, a count or a category, built on the pill.
- Card (opens in a new tab): A surface with a header, body and footer, built on the base card styles.
- Alert (opens in a new tab): A callout that draws attention to a message, with an icon, a title and an action.
- Kbd (opens in a new tab): A keyboard key or shortcut, as text.