Componentfeedback2.61 KB gzipZero dependencies
Drawer
Bottom slide-up drawer with pull handle, backdrop blur, and focus trap.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add drawerOr install the full npm package:
npm install bigbulluiUsage
tsx6 lines
import { Drawer, DrawerTrigger, DrawerContent } from "@/components/ui/drawer"; <Drawer> <DrawerTrigger asChild><button>Open Drawer</button></DrawerTrigger> <DrawerContent>Sheet content</DrawerContent></Drawer>Source code
drawer.tsx + 4 helpersZero third-party dependencies (5 local files shown in tabs below).
tsxdrawer.tsx465 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { getFocusable, hideBackgroundSiblings, lockBodyScroll, registerEscapeLayer, trapFocus,} from "./lib/focus-trap";import { useIsMounted } from "./lib/react-compat";import { Slot } from "./lib/slot"; interface DrawerContextValue { open: boolean; setOpen: (open: boolean) => void;Props
Interactive Prop Playground
Tweak parsed AST props below to generate ready-to-paste JSX.
tsx3 lines
import { Drawer } from "@/components/ui/drawer"; <Drawer />| Prop | Type | Description |
|---|---|---|
| open | boolean | Controlled open visibility state. |
| defaultOpen | boolean | Initial open state when uncontrolled. (Default: false) |
| onOpenChange | (open: boolean) => void | Callback invoked on open change. |
| children | React.ReactNode | Child elements rendered inside the component. |