Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Drawer examples · Bottom

Bottom Drawer with Form for React

A bottom drawer with name, email and phone fields for adding a contact.

Framework
UI library

A short form in a bottom drawer: Name, Email and Phone, with Add Contact and Cancel in the footer. Each field is a Field with its label, and the inputs use the right type, so phones show the email keyboard and the number pad.

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

Which fields does the form have?

Name, a text input; Email, type="email"; and Phone, type="tel". Each has a placeholder and sits in a Field inside a FieldGroup.

How are the labels tied to the inputs?

Each label and input share a Field, so the label names the input and clicking it focuses the field. The FieldLabel points at its input with htmlFor and a matching id.

Does Add Contact submit anything?

Not yet: the fields aren't in a form and the button has no handler. Wrap the fields in a form, give the button type="submit", and close the drawer once the contact is saved: Pass open to Drawer; onOpenChange receives the next boolean.

How does Cancel close the drawer?

It's a DrawerClose, so pressing it dismisses the drawer and drops what was typed. The Button goes in the render prop of DrawerClose.

Why do the inputs set a type?

type="email" and type="tel" bring up the email keyboard and the number pad on phones, and help the browser autofill. Name uses type="text".

How does Add Contact open the drawer?

An outline button opens the drawer. Its text, Add Contact, is the accessible name. The Button goes in the render prop of DrawerTrigger.