Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Menubar examples · Standard

Menubar with Submenu for React

A File menu with an Open Recent submenu listing three recent documents.

Framework
UI library

Recent files belong one level down, out of the way of New and Save. This menubar's File menu has New File and Save, with an Open Recent submenu in between that lists Document 1.txt, Document 2.txt and Document 3.txt. It fits editors and document apps.

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

How is Open Recent nested?

MenubarSub wraps a MenubarSubTrigger that reads Open Recent and a MenubarSubContent with the documents. The submenu opens beside its trigger and flips to the other side when there's no room.

Where does the arrow on Open Recent come from?

MenubarSubTrigger draws the chevron at the end of the row itself; the demo adds no icon.

What are the rows inside the submenu?

Document 1.txt, Document 2.txt and Document 3.txt, as plain MenubarItems.

What else is in the File menu?

New File above Open Recent and Save below it, both plain items.

Can I open the submenu from the keyboard?

Yes. Move to Open Recent and press Arrow Right or Enter. Arrow Left closes the submenu and returns to Open Recent.

How do I add another recent file?

Add a MenubarItem inside MenubarSubContent. For a real list, map over your recent files and give each row a key.