Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Item examples · Media

Item with Icon Media for React

A security alert item with a shield icon, a short message and a Review button.

Framework
UI library

A notice that belongs in a list rather than a banner: a shield icon, Security Alert, New login detected from unknown device, and a Review button. This React example uses ItemMedia with variant="icon" for the shield, ItemContent for the text and an outline Button in ItemActions, on an outline Item.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

What does variant icon do for ItemMedia?

It sizes an icon that has no size class of its own to size-4, so icons line up from row to row without classes on each. When the row has a description, ItemMedia also moves to the top so the icon lines up with the title.

What icons work best in ItemMedia?

Simple ones that say what kind of row it is: a shield for security, a bell for a notification, a file for a document. The icon is decorative here, marked aria-hidden="true", because the title says what it means.

When should ItemMedia hold an icon and when an avatar?

An avatar when the row is about a person. An icon, as with this shield, when the row is a system event, a setting, or a file type. For a picture, set ItemMedia variant to image.

What actions suit an alert row?

One clear next step, Review here, as a small outline button. A second, quieter action such as Dismiss can sit beside it in ItemActions, which spaces its children with a small gap.

Does the shield set its own size or color?

ShieldAlertIcon has aria-hidden and no color class, so it inherits the tile. variant="icon" sizes an icon that has no size class. The title Security Alert and the description carry the meaning.

Are icon media items accessible to screen readers?

Yes: the icon is hidden from assistive technology, and the row is read as the title, the description and the Review button. If the icon is the only place a meaning appears, drop aria-hidden and give it a label, or put that meaning in text.