Skip to content
MIZU.

Drawer

A panel that slides in from an edge for filters, details and quick edits, with all of Dialog's modal care.

View .md

Live — this one is real

Usage

tsx
"use client";

import { useState } from "react";
import {
  Drawer,
  DialogTitle,
  DialogBody,
  DialogFooter,
  DialogClose,
  Button,
  Checkbox,
} from "mizu-ui";

export function Example() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Filter incidents</Button>
      <Drawer open={open} onOpenChange={setOpen} label="Filters">
        <DialogClose />
        <DialogTitle>Filters</DialogTitle>
        <DialogBody>
          <Checkbox label="Only open incidents" defaultChecked />
          <Checkbox label="Assigned to me" />
        </DialogBody>
        <DialogFooter>
          <Button onClick={() => setOpen(false)}>Show results</Button>
        </DialogFooter>
      </Drawer>
    </>
  );
}

It starts with "use client" because it keeps state or passes functions to components, so it pastes into a Next.js page as it is. Other React setups ignore the directive.

Source & setup

Add this component to your project with the shadcn CLI. The command copies its source into your configured UI directory, with base.css, Mizu’s tokens, and the stylesheets that hold its rules. Each rule lives in one stylesheet, so components you add together never repeat CSS. In a project without a components.json, run npx shadcn@latest init 0xuser64bit/mizu/preset first: plain init installs shadcn’s theme into your global CSS. Then load the fonts.

sh
npx shadcn@latest add 0xuser64bit/mizu/drawer 0xuser64bit/mizu/dialog 0xuser64bit/mizu/button 0xuser64bit/mizu/checkbox

The example also uses Dialog and Button and Checkbox, so the command adds them too.

Every component imports from its own path, its name in kebab case. To paste the example, replace its mizu-ui import with:

tsx
import { Drawer } from "@/components/ui/mizu/drawer";
import { DialogTitle, DialogBody, DialogFooter, DialogClose } from "@/components/ui/mizu/dialog";
import { Button } from "@/components/ui/mizu/button";
import { Checkbox } from "@/components/ui/mizu/checkbox";

For npm imports, import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Uses native React and CSS; install the package peers for root imports. A Client Component: its source starts with “use client”.

Inspect composite/Drawer.tsx

Source is included in the npm package under src/composite/Drawer.tsx.

Open full source ↗

Props

PropTypeDefaultDescription
open / onOpenChangeboolean / (open: boolean) => void—Controlled visibility. Escape, the backdrop and DialogClose ask to close through onOpenChange.
labelstring—Accessible name of the drawer.
side"right" | "left" | "bottom""right"The edge it slides from. Side drawers leave 48px of the page showing on a phone, to tap away.
childrenReactNode—Compose DialogTitle, DialogBody, DialogFooter and DialogClose inside, as in a Dialog.

Accessibility

A native modal dialog: focus moves inside and returns to the trigger, the page behind is inert and keeps its scroll position, and Escape closes it.

Motion

The panel slides in from its edge with expo easing; reduced motion shows it in place.

Works alongside