Drawer
Side sheet. 2 sides.
import * as React from "react";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Drawer } from "@/components/ui/drawer";
export default function Example() {
const [open, setOpen] = React.useState(false);
return (
<>
<Button variant="outline" onClick={() => setOpen(true)}>Open filters</Button>
<Drawer open={open} onClose={() => setOpen(false)} title="Filters" footer={<><Button variant="ghost" onClick={() => setOpen(false)}>Reset</Button><Button onClick={() => setOpen(false)}>Show 14 teas</Button></>}>
<div style={{ display: "grid", gap: 12 }}>
<Checkbox label="Green tea" defaultChecked />
<Checkbox label="Black tea" />
<Checkbox label="Under ৳500" />
</div>
</Drawer>
</>
);
}
Installation
$ npx uix-ui@latest add drawerThis copies the file into components/ui/drawer.tsx in your project. npx shadcn@latest add @uix/drawer works too.
Usage
import { Drawer } from "@/components/ui/drawer";
<>
<Button variant="outline" onClick={() => setOpen(true)}>Open filters</Button>
<Drawer open={open} onClose={() => setOpen(false)} title="Filters" footer={<><Button variant="ghost" onClick={() => setOpen(false)}>Reset</Button><Button onClick={() => setOpen(false)}>Show 14 teas</Button></>}>
<div style={{ display: "grid", gap: 12 }}>
<Checkbox label="Green tea" defaultChecked />
<Checkbox label="Black tea" />
<Checkbox label="Under ৳500" />
</div>
</Drawer>
</>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
side | right | left | "right" | |
open | boolean | – | |
onClose | () => void | – | |
title | React.ReactNode | – | |
footer | React.ReactNode | – | Buttons pinned to the bottom. |
Everything else is passed to the root element, so className, aria-* and event handlers work as usual.
Dependencies
Installed for you by the CLI.
class-variance-authorityclsxtailwind-merge
lib/utils.tscomponents/ui/icons.tsx