shadcn.io is not affiliated with official shadcn/ui
Item examples · Interactive
Item in Dropdown for React
A Select button that opens a menu of people, each row an item with an avatar, a username and a masked email.
A menu option sometimes needs more than a word: a face, a name and an address to tell people apart. This React example puts a small Item inside each Dropdown Menu item, with an Avatar in ItemMedia and the username and masked email in ItemContent. The menu item drops its padding (p-0) and the Item brings its own (p-2, w-full), the menu is w-72 wide and opens under the outline Select button, aligned to its end.
Preview
Installation
FAQ
When should menu options use an Item instead of plain text?
When each option carries more than one piece of information, like a name and an email, or needs a picture to be recognized. For short labels such as Edit or Delete, plain text and an icon are enough. The menu's keyboard handling is the same either way.
Why p-0 on the menu item and p-2 on the Item?
Both parts have padding, and together they would double it. Removing it from the menu item and setting it on the Item lets one part own the spacing, and w-full makes the Item fill the row so the highlight covers it edge to edge.
How does ItemMedia hold the avatar?
ItemMedia keeps the avatar from shrinking and aligns it with the text; when the row has a description, it moves to the top of the row. The Avatar here is its default size, and AvatarFallback shows the username's first letter if the picture doesn't load.
Why use size sm for Items in a menu?
size="sm" tightens the Item's gap and padding so more people fit before the menu scrolls. The example then sets p-2 on top of it to match the menu's own items. For an even tighter menu there's xs.
Related
- Item GroupThree people in an item group, divided by
- Item with AvatarAn outline item with a person's avatar
- Item as LinkTwo items rendered as links: one to a
- Simple Dropdown with Icons Dropdown MenuA short menu behind a dots button with an
- Avatar StandardA round avatar with a profile picture and
- Simple Single Select ComboboxA single-select combobox that opens from