Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Drawer examples · Left

Left Drawer with Search for React

A left drawer with a search field above Main Menu and Settings groups of navigation buttons.

Framework
UI library

Navigation with a search field on top. The field is an Input Group with a search icon, and the items sit under two small headings, Main Menu and Settings, each its own labeled nav. The drawer's title is visually hidden, since the search field leads the panel.

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

Does the search filter the items?

Not in this demo: the input is uncontrolled. Keep the query in state and hide the items whose label doesn't match, or send it to your search page.

How are the groups marked up?

Each group has a small uppercase heading and its own nav with an aria-label, Main menu and Settings, so screen readers list them as separate landmarks.

Why is the title hidden?

DrawerTitle names the dialog for assistive tech, so every drawer renders one; give it sr-only when the design has no visible heading. Here it reads Navigation and has sr-only, so the search field sits at the top.

How is the menu button labeled?

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

How does the drawer open from the left?

swipeDirection="left" on Drawer puts it on the left edge. The prop names the swipe that closes the drawer, so left docks it on the left; leave it out for a bottom drawer.