Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Drawer examples · Left

Left Drawer File Explorer for React

A left drawer with a file tree whose folders expand and collapse to show their files.

Framework
UI library

A small file explorer in a left drawer. Projects is open from the start and holds the Website and App folders, each a Collapsible with its files. The chevron turns as a folder opens, and the indent grows with each level.

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 the tree built?

From nested Collapsibles. Projects sets defaultOpen, and Website and App map from a static list of folders, each with its files inside CollapsibleContent.

How is each level indented?

Every CollapsibleContent has ms-4, so each level starts a step further in, on the reading side.

How does the chevron show a folder's state?

The trigger has aria-expanded while the folder is open, and the chevron's group-aria-expanded:rotate-90 turns it down.

Do the files open anything?

No, they're ghost buttons with a file icon and no handler. Open the file from each one, and close the drawer if it should get out of the way. Pass open to Drawer; onOpenChange receives the next boolean.

How is the files button labeled?

An outline icon button opens the drawer. Its aria-label, Open files, is the accessible name; the icon is aria-hidden. The Button goes in the render prop of DrawerTrigger.

Where is the drawer's title?

Files, above the tree, is the DrawerTitle. DrawerTitle names the dialog for assistive tech, so every drawer renders one; give it sr-only when the design has no visible heading.