shadcn.io is not affiliated with official shadcn/ui
Context Menu examples · Standard
Context Menu with Labels for React
A context menu with My Account and Support sections under labels, and a destructive Log Out.
Two labeled sections, My Account with Profile and Settings and Support with Help Center, then Log Out at the end. Labels name each part of a longer menu so people scan sections instead of items.
Preview
Installation
FAQ
How are the section labels added?
Each label is a ContextMenuGroupLabel at the top of a ContextMenuGroup with the items it names. The label isn't selectable; screen readers announce it as the group's name.
Where do the separators go?
Between the sections and before Log Out, each a ContextMenuSeparator outside the groups.
How is the destructive item styled?
variant="destructive" on ContextMenuItem colors it with the destructive token, icon included. Keep it last, after a separator, and confirm with an Alert Dialog when it can't be undone.
How are the icons added?
A Lucide icon as the first child of each item, hidden from assistive tech since the label names the action. The menu styles size and space it.
Related
- Context Menu with SeparatorsA context menu that separates Edit, the
- Layer Management Menu Context MenuA labeled Layer Options context menu to
- File Properties Menu Context MenuA labeled File Management context menu
- Context Menu with Radio ItemsA context menu that picks one Panel
- Context Menu with CheckboxesA context menu of view options that
- Context Menu with Icons and ShortcutsA context menu whose items each have an