# Item

> List row with optional media, a truncating title and description, optional actions and an optional whole-row link.

- Kind: ui · Category: Data display · Interactivity: native
- Install: `npx shadcn@latest add @haze/item`
- File: `src/components/haze/ui/item.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/item

## Use when
- Rows of files, people, repositories or settings, each with an icon or avatar and a short description
- A row where the whole area opens a page; add a tag or plain text on the right if needed
- A row with a button on the right and no link
- A bordered row that stands alone, using the outline variant

## Avoid when
- Comparing many fields across rows; table aligns columns
- A big content box with a header and footer; use card

## Alternatives
- [card](https://hazeui.com/ui/card.md)
- [table](https://hazeui.com/ui/table.md)
- [avatar](https://hazeui.com/ui/avatar.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| title | `string` |  | yes | Row title, cut off with an ellipsis when too long. A link when href is set. |
| description | `string` |  | no | Muted line under the title, cut off with an ellipsis when too long. |
| href | `string` |  | no | Makes the title a link whose click area stretches over the whole row through an after: pseudo-element, and adds a hover fill and a trailing chevron. A linked row should not contain a button. |
| variant | `"default" \| "outline"` | "default" | no | default has no border; outline draws a bordered panel. |
| class | `string` |  | no | Extra classes on the row. |
| media slot | `slot` |  | no | Avatar, icon or thumbnail at the left edge. For an icon, wrap it in a 36 px chip: size-9 rounded-lg bg-foreground/5 inset-ring inset-ring-border. |
| actions slot | `slot` |  | no | A tag or text at the right edge of a linked row, or buttons in a row with no link. It sits above the link overlay. |

## Accessibility
- The title and description truncate with an ellipsis instead of wrapping; a linked row shows a chevron that nudges on hover.
- Renders a <div>. To make a list, wrap several items yourself in <ul role="list"> with an <li> each, so the count is announced.
- Only the title is a link, so a screen reader hears one link per row with the title as its name instead of the whole row text.
- A row is either a link or holds buttons, never both: a button inside a link is nested interactive content. The actions slot sits above the stretched link (z-10), which suits non-interactive content such as a tag.
- The chevron is decorative and aria-hidden.
- Key Tab, Enter: Focus the row link and follow it; buttons in the right slot of an unlinked row are separate tab stops

## Agent prompts

### Install and use

Install the Haze UI component "Item" with `npx shadcn@latest add @haze/item`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Item from "@/components/haze/ui/item.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/ui/item.md

### Customize with real content

Adapt the Haze item ui for our product. Replace the demo values of these props with our real content: title, description, href, variant, class, media slot, actions slot. Keep the layout, the heading level rules and these accessibility details: The title and description truncate with an ellipsis instead of wrapping; a linked row shows a chevron that nudges on hover. Renders a <div>. To make a list, wrap several items yourself in <ul role="list"> with an <li> each, so the count is announced. Only the title is a link, so a screen reader hears one link per row with the title as its name instead of the whole row text. A row is either a link or holds buttons, never both: a button inside a link is nested interactive content. The actions slot sits above the stretched link (z-10), which suits non-interactive content such as a tag. The chevron is decorative and aria-hidden. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using item, check it fits: use it when rows of files, people, repositories or settings, each with an icon or avatar and a short description; a row where the whole area opens a page; add a tag or plain text on the right if needed; a row with a button on the right and no link; a bordered row that stands alone, using the outline variant. Avoid it when comparing many fields across rows; table aligns columns; a big content box with a header and footer; use card. Alternatives: @haze/card, @haze/table, @haze/avatar.

## Example requests that should lead here
- List three files as linked outline items with a file icon and a type tag
- Show team members as items with an avatar, a role and an Invite button

## Source

```astro
---
import { ChevronRight } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface Props {
  title: string;
  description?: string;
  /** When set, the title is a link and the whole row is clickable. A linked row should not hold buttons in its actions slot; use a tag or plain text there. */
  href?: string;
  /** default has no frame; outline draws a bordered panel. */
  variant?: "default" | "outline";
  class?: string;
}

const { title, description, href, variant = "default", class: className } = Astro.props;
const hasMedia = Astro.slots.has("media");
const hasActions = Astro.slots.has("actions");
const variants = {
  default: "rounded-lg px-3 py-2.5",
  outline: "rounded-xl border border-border bg-card p-3",
};
const linkClasses =
  "rounded-sm after:absolute after:inset-0 after:content-[''] focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring";
---

<div
  class={cn(
    "group relative flex items-center gap-3",
    variants[variant],
    href && "transition-colors duration-150 hover:bg-accent",
    href && variant === "outline" && "hover:border-frame-strong",
    className,
  )}
>
  {
    hasMedia && (
      <div class="shrink-0">
        <slot name="media" />
      </div>
    )
  }
  <div class="grid min-w-0 flex-1 gap-0.5">
    {
      href ? (
        <a href={href} class={cn("w-fit max-w-full truncate text-[0.8125rem]/5 font-medium text-foreground", linkClasses)}>
          {title}
        </a>
      ) : (
        <p class="truncate text-[0.8125rem]/5 font-medium text-foreground">{title}</p>
      )
    }
    {description && <p class="truncate text-[0.8125rem]/5 text-muted-foreground">{description}</p>}
  </div>
  {
    hasActions && (
      <div class="relative z-10 flex shrink-0 items-center gap-2">
        <slot name="actions" />
      </div>
    )
  }
  {
    href && (
      <ChevronRight
        class="pointer-events-none size-4 shrink-0 text-muted-foreground transition-[translate] duration-200 ease-snappy group-hover:translate-x-0.5"
        aria-hidden="true"
      />
    )
  }
</div>
```
