Componentfeedback2.61 KB gzipZero dependencies

Drawer

Bottom slide-up drawer with pull handle, backdrop blur, and focus trap.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add drawer

Or install the full npm package:

npm install bigbullui

Usage

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 helpers

Zero 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 />
PropTypeDescription
openbooleanControlled open visibility state.
defaultOpenbooleanInitial open state when uncontrolled. (Default: false)
onOpenChange(open: boolean) => voidCallback invoked on open change.
childrenReact.ReactNodeChild elements rendered inside the component.