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.
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
Installation
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.
Related
- Item in DropdownA Select button that opens a menu of
- Item with AvatarAn outline item with a person's avatar
- Item with HeaderThree model cards in a grid, each an item
- Item with Image MediaA list of songs as link items, each with
- Avatar StandardA round avatar with a profile picture and
- Item SizesA default-size item with an action button