Skip to content
Nana UI

Data Display & Media

Item

A row that shows one thing — an icon, avatar or image, a title, a description and actions — on its own or in a list, and opens it when clicked.

View .md Download

An item is one row: a policy, a person, a file, a setting. It sets out a picture, a title and a line about it, with actions at the end, and lines up with the items around it. For rows of data with columns, use the table; for a block with its own header and body, the card.

Renew Renew Renew Assign

KDA 123A · renews 12 March

Four people · paid monthly

Kilimani flat · lapsed

Wanjiru Kamau

Claims assessor, Nairobi

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add item --framework web-components
npx @nana-tec/ui add item --framework svelte

Lands in src/lib/components/ui/item/ as NanaItem.svelte and NanaItemGroup.svelte, with their classes in styles/item.ts. Classes resolve to the design tokens. Requires Tailwind v4.

<script lang="ts">
import { NanaItem, NanaItemGroup } from '$lib/components/ui/item';
</script>
<NanaItemGroup label="Policies" divided>
<NanaItem title="Motor comprehensive" description="KDA 123A" href="/policies/42">
{#snippet media()}<NanaIcon icon={truckIcon} />{/snippet}
{#snippet actions()}<NanaButton size="sm" variant="ghost">Renew</NanaButton>{/snippet}
</NanaItem>
</NanaItemGroup>

Anything passed as children shows under the description.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/item";

Copied in with npx @nana-tec/ui add item? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<nana-item-group label="Policies" divided>
<nana-item title="Motor comprehensive" description="KDA 123A" href="/policies/42">
<nana-icon slot="media" name="truck"></nana-icon>
<nana-button slot="actions" size="sm" variant="ghost">Renew</nana-button>
</nana-item>
</nana-item-group>

Content in the default slot shows under the description.

With href, the title becomes a link stretched over the whole row, so a click anywhere on it opens the item, and the row tints on hover and presses in slightly. The actions sit above the link and do their own thing. Keyboard users reach the link and then each action, in order. A disabled item dims, and its link stays announced but goes nowhere.

VariantUse
defaultNo border or fill; for rows in a divided group or a panel
outlineA light border on the surface, for an item on its own
mutedA tinted fill, for an item that sits back

size is md or the denser sm. The media box is sized for an icon by default; set the media to avatar to let an avatar keep its own size, or image to fill the box with a picture.

A group is a list, named by label, and its items are its list items. Items are spaced apart; with divided they are joined in one outlined box with a line between each.

  • A group is a list named by label, and each item in it a listitem, so screen readers say how many there are.
  • The title is the link’s name, so it should say what opens: “Motor comprehensive”, not “View”.
  • Actions are separate buttons, never inside the link; name an icon-only action, as in “Renew motor comprehensive”.
  • Media is decoration unless it says something the title does not; an avatar with a name already has one.

Properties

PropertyAttributeTypeDefaultDescription
descriptiondescriptionstring''A line under the title, clamped to two lines
disableddisabledbooleanfalseDims the row and stops the link
hrefhrefstring''Where the row leads; the title becomes a link stretched over the row
mediamediaItemMedia'icon'What the media slot holds, which sets its box
relrelstring''The link's relationship
sizesizeItemSize'md'The row's density
targettarget'_blank' | '_self' | '_parent' | '_top' | ''''Where the link opens
titletitlestring''The row's title
variantvariantItemVariant'default'The look of the row

Slots

SlotDescription
mediaAn icon, avatar or image at the start
(default)Extra content under the description
actionsButtons at the end, clickable on their own

CSS parts

PartDescription
::part(base)The row, with interactive when it has a link and disabled when disabled
::part(media)The media box
::part(content)The title, description and extra content
::part(title)The title
::part(link)The title's link, stretched over the row
::part(description)The description
::part(actions)The actions box

CSS custom properties

PropertyDescription
--nana-item-bgBackground of the row
--nana-item-borderBorder of the row
--nana-item-dividerColour of the line above the row in a divided group
--nana-item-radiusCorner radius of the row

Properties

PropertyAttributeTypeDefaultDescription
divideddividedbooleanfalseJoins the items in one outlined box with lines between them
labellabelstring''Names the list for screen readers

Slots

SlotDescription
(default)nana-item children

CSS parts

PartDescription
::part(list)The list around the items, with divided when joined

NanaItem

PropTypeDefault
variantItemVariant'default'
sizeItemSize'md'
titlestring
descriptionstring
hrefstring
disabledbooleanfalse
mediaVariantItemMedia'icon'
mediaSnippet
actionsSnippet
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'title'>.

NanaItemGroup

PropTypeDefault
labelstring
dividedbooleanfalse
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class'>.