Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Item examples · Layout

Item Group for React

Three people in an item group, divided by separators, each with an avatar, an email and an invite button.

Framework
UI library

A list of people reads better as one block than as separate cards. This React example maps three people into an ItemGroup, each row an Item with an Avatar, the username and a masked email, and a round ghost Button to invite them. An ItemSeparator draws a rule between rows but not after the last one.

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

When should Items go in an ItemGroup?

Whenever several rows form one list. ItemGroup stacks them with a gap that follows their size and gives the block the list role, which is why each row here has role="listitem". A single row on its own doesn't need a group.

How does ItemSeparator work between Items?

ItemSeparator is a horizontal Separator with a little vertical margin. Render it between rows, skipping the last index, so the list doesn't end with a stray rule. For rows that already have borders, as in the outline variant, you can drop the separators and rely on the group's gap.

How does the loop render a row and a separator together?

Each pass of the loop renders two siblings, the Item and its separator, keyed by the username, with no element wrapped around them. An extra wrapper would sit between the list and its items and break the layout. A Fragment carries the key without adding anything to the DOM.

What actions suit a grouped list?

One small action per row works best, like the icon button here. Use the icon-md size, pill for a round shape and the ghost variant so the buttons don't outweigh the names. An icon-only button needs an aria-label that names the row, such as Invite haydenbleasel.

Should every Item in a group have the same media?

Yes: matching media keeps titles lined up down the list. If a person has no picture, AvatarFallback shows the first letter of the username in the same size, so the row still lines up.

How do screen readers read an ItemGroup?

The group is announced as a list and each row as a list item, so people hear how many entries there are. Each button's aria-label names its person, so moving from button to button doesn't just repeat Invite.