···11+---
22+title: Drawer
33+description: A modal drawer component that slides in from the side for displaying content in an overlay.
44+---
55+66+import { PropDocs } from '../../lib/PropDocs'
77+import { Example } from '../../lib/Example'
88+import { Basic } from '../../examples/drawer/basic'
99+import { DrawerSizes } from '../../examples/drawer/sizes'
1010+import { DrawerDirections } from '../../examples/drawer/directions'
1111+import { DrawerNonModal } from '../../examples/drawer/non-modal'
1212+1313+<Example src={Basic} />
1414+1515+## Installation
1616+1717+Run the following command to add the drawer component to your project.
1818+1919+```bash
2020+pnpm hip install drawer
2121+```
2222+2323+## Props
2424+2525+This component is built using the [React Aria Dialog](https://react-spectrum.adobe.com/react-aria/Dialog.html).
2626+2727+<PropDocs components={["Drawer", "DrawerHeader", "DrawerDescription", "DrawerBody", "DrawerFooter"]} />
2828+2929+## Features
3030+3131+### Sizes
3232+3333+Drawers support different sizes to accommodate various content types.
3434+3535+<Example src={DrawerSizes} />
3636+3737+### Directions
3838+3939+Drawers can be positioned in four different directions: left, right, top, and bottom.
4040+4141+<Example src={DrawerDirections} />
4242+4343+### Non-Modal
4444+4545+If you need the page to be interactive while the drawer is open, you can set the `isNonModal` prop to `true`.
4646+4747+<Example src={DrawerNonModal} />
4848+4949+## Related Components
5050+5151+- [Dialog](/docs/components/dialog) - For centered modal dialogs
5252+- [AlertDialog](/docs/components/alert-dialog) - For critical actions and confirmations
5353+- [Popover](/docs/components/popover) - For non-modal overlays
5454+- [Button](/docs/components/button) - For drawer action buttons
5555+- [Form](/docs/components/form) - For forms within drawers
5656+
+23
apps/docs/src/examples/drawer/basic.tsx
···11+import { Button } from "@/components/button";
22+import {
33+ Drawer,
44+ DrawerHeader,
55+ DrawerBody,
66+ DrawerFooter,
77+} from "@/components/drawer";
88+import { Body } from "@/components/typography";
99+1010+export function Basic() {
1111+ return (
1212+ <Drawer trigger={<Button>Open Drawer</Button>}>
1313+ <DrawerHeader>Drawer Title</DrawerHeader>
1414+ <DrawerBody>
1515+ <Body>This is the drawer content. You can put any content here.</Body>
1616+ </DrawerBody>
1717+ <DrawerFooter>
1818+ <Button variant="secondary">Cancel</Button>
1919+ <Button>Confirm</Button>
2020+ </DrawerFooter>
2121+ </Drawer>
2222+ );
2323+}
+54
apps/docs/src/examples/drawer/directions.tsx
···11+import { Button } from "@/components/button";
22+import { Drawer, DrawerHeader, DrawerBody } from "@/components/drawer";
33+import { Flex } from "@/components/flex";
44+import { Body } from "@/components/typography";
55+66+export function DrawerDirections() {
77+ return (
88+ <Flex gap="4" wrap>
99+ <Drawer
1010+ size="sm"
1111+ trigger={<Button>Open Left Drawer</Button>}
1212+ direction="left"
1313+ >
1414+ <DrawerHeader>Left Drawer</DrawerHeader>
1515+ <DrawerBody>
1616+ <Body>This drawer slides in from the left side.</Body>
1717+ </DrawerBody>
1818+ </Drawer>
1919+2020+ <Drawer
2121+ size="sm"
2222+ trigger={<Button>Open Right Drawer</Button>}
2323+ direction="right"
2424+ >
2525+ <DrawerHeader>Right Drawer</DrawerHeader>
2626+ <DrawerBody>
2727+ <Body>This drawer slides in from the right side.</Body>
2828+ </DrawerBody>
2929+ </Drawer>
3030+3131+ <Drawer
3232+ size="sm"
3333+ trigger={<Button>Open Top Drawer</Button>}
3434+ direction="top"
3535+ >
3636+ <DrawerHeader>Top Drawer</DrawerHeader>
3737+ <DrawerBody>
3838+ <Body>This drawer slides in from the top.</Body>
3939+ </DrawerBody>
4040+ </Drawer>
4141+4242+ <Drawer
4343+ size="sm"
4444+ trigger={<Button>Open Bottom Drawer</Button>}
4545+ direction="bottom"
4646+ >
4747+ <DrawerHeader>Bottom Drawer</DrawerHeader>
4848+ <DrawerBody>
4949+ <Body>This drawer slides in from the bottom.</Body>
5050+ </DrawerBody>
5151+ </Drawer>
5252+ </Flex>
5353+ );
5454+}
···11+import { Button } from "@/components/button";
22+import {
33+ Drawer,
44+ DrawerHeader,
55+ DrawerBody,
66+ DrawerFooter,
77+} from "@/components/drawer";
88+import { Body } from "@/components/typography";
99+1010+export function DrawerNonModal() {
1111+ return (
1212+ <Drawer trigger={<Button>Open Non-Modal Drawer</Button>} isNonModal>
1313+ <DrawerHeader>Non-Modal Drawer</DrawerHeader>
1414+ <DrawerBody>
1515+ <Body>
1616+ This drawer is non-modal, meaning you can still interact with the page
1717+ behind it while it's open. Try clicking outside the drawer or
1818+ interacting with other elements on the page.
1919+ </Body>
2020+ </DrawerBody>
2121+ <DrawerFooter>
2222+ <Button variant="secondary">Cancel</Button>
2323+ <Button>Confirm</Button>
2424+ </DrawerFooter>
2525+ </Drawer>
2626+ );
2727+}
+41
apps/docs/src/examples/drawer/sizes.tsx
···11+import { Button } from "@/components/button";
22+import {
33+ Drawer,
44+ DrawerHeader,
55+ DrawerBody,
66+} from "@/components/drawer";
77+import { Flex } from "@/components/flex";
88+import { Body } from "@/components/typography";
99+1010+export function DrawerSizes() {
1111+ return (
1212+ <Flex gap="4" wrap>
1313+ <Drawer trigger={<Button>Small Drawer</Button>} size="sm">
1414+ <DrawerHeader>Small Drawer</DrawerHeader>
1515+ <DrawerBody>
1616+ <Body>This is a small drawer with minimal content.</Body>
1717+ </DrawerBody>
1818+ </Drawer>
1919+2020+ <Drawer trigger={<Button>Medium Drawer</Button>} size="md">
2121+ <DrawerHeader>Medium Drawer</DrawerHeader>
2222+ <DrawerBody>
2323+ <Body>
2424+ This is a medium drawer with more space for content.
2525+ </Body>
2626+ </DrawerBody>
2727+ </Drawer>
2828+2929+ <Drawer trigger={<Button>Large Drawer</Button>} size="lg">
3030+ <DrawerHeader>Large Drawer</DrawerHeader>
3131+ <DrawerBody>
3232+ <Body>
3333+ This is a large drawer with even more space for content.
3434+ Perfect for forms, detailed information, or complex layouts.
3535+ </Body>
3636+ </DrawerBody>
3737+ </Drawer>
3838+ </Flex>
3939+ );
4040+}
4141+