Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Right Drawer Settings Panel for React

A right Settings drawer with notification and privacy switches, plus Save Changes and Cancel.

A right panel titled Settings, with the line Manage your preferences. Switches sit under Notifications and Privacy, and Save Changes and Cancel sit at the bottom.

Use it for a few preferences beside the page on a phone. A long settings form belongs on its own page, not in a Sheet. In React, Base UI does not save the switches.

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.

Anatomy

Drawer anatomy: grabber, title, description, content, close

Usage

<Drawer swipeDirection="right">
  <DrawerTrigger
    render={
      <Button aria-label="Open settings" size="icon-md" variant="outline" />
    }
  >
    <SettingsIcon aria-hidden="true" />
  </DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Settings</DrawerTitle>
      <DrawerDescription>Manage your preferences</DrawerDescription>
    </DrawerHeader>
    <div className="flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto p-4">
      <FieldSet>
        <FieldLegend variant="label">Notifications</FieldLegend>
        <FieldGroup className="gap-3">
          <Field orientation="horizontal">
            <FieldLabel className="font-normal" htmlFor="settings-email">
              Email notifications
            </FieldLabel>
            <Switch id="settings-email" />
          </Field>
          <Field orientation="horizontal">
            <FieldLabel className="font-normal" htmlFor="settings-push">
              Push notifications
            </FieldLabel>
            <Switch defaultChecked id="settings-push" />
          </Field>
          <Field orientation="horizontal">
            <FieldLabel className="font-normal" htmlFor="settings-sms">
{/* The rest of the file is under Installation. */}

FAQ

How are the settings grouped?

Two FieldSets with a FieldLegend each: Notifications, with Email, Push and SMS, and Privacy, with Profile visible and Show activity.

Which switches start on?

Push notifications, Profile visible and Show activity. Email and SMS notifications start off.

How is each switch labeled?

Each row is a horizontal Field: the FieldLabel at the start names the Switch at the end, and clicking the label flips it.

Does Save Changes store the settings?

Not yet: the switches are uncontrolled and Save Changes has no handler. Control the switches, save on press, and close the drawer once it's stored: Pass open to Drawer; onOpenChange receives the next boolean.

How is the settings button labeled?

An outline icon button opens the drawer. Its aria-label, Open settings, 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 right?

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

API Reference

Drawer

Sets swipeDirection="right". The rest is on the Drawer page.

Button

Sets aria-label="Open settings", size="icon-md" and variant="outline". The rest is on the Button page.

Field

Sets variant="label", orientation="horizontal", htmlFor="settings-email", htmlFor="settings-push", htmlFor="settings-sms" and htmlFor="settings-profile-visible". The rest is on the Field page.

Switch

Sets id="settings-email", defaultChecked, id="settings-push", id="settings-sms", id="settings-profile-visible" and id="settings-show-activity". The rest is on the Switch page.