Drawer
boldkit/drawerFreeComponent
A drawer component that slides in from the edge of the screen
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/drawer.jsonSource
1import * as React from 'react'2import { Drawer as DrawerPrimitive } from 'vaul'3import { cn } from '@/lib/utils'45const Drawer = ({6 shouldScaleBackground = true,7 ...props8}: React.ComponentProps<typeof DrawerPrimitive.Root>) => (9 <DrawerPrimitive.Root10 shouldScaleBackground={shouldScaleBackground}11 {...props}12 />13)14Drawer.displayName = 'Drawer'1516const DrawerTrigger = DrawerPrimitive.Trigger1718const DrawerPortal = DrawerPrimitive.Portal1920const DrawerClose = DrawerPrimitive.Close2122const DrawerOverlay = React.forwardRef<23 React.ElementRef<typeof DrawerPrimitive.Overlay>,24 React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>25>(({ className, ...props }, ref) => (26 <DrawerPrimitive.Overlay27 ref={ref}28 className={cn('fixed inset-0 z-50 bg-black/70', className)}29 {...props}30 />31))32DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName3334const DrawerContent = React.forwardRef<35 React.ElementRef<typeof DrawerPrimitive.Content>,36 React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>37>(({ className, children, ...props }, ref) => (38 <DrawerPortal>39 <DrawerOverlay />40 <DrawerPrimitive.Content41 ref={ref}42 className={cn(43 'fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col border-3 border-b-0 border-foreground bg-background shadow-[0px_-8px_0px_hsl(var(--shadow-color))]',44 className45 )}46 {...props}47 >48 <div className="mx-auto mt-4 h-2 w-[100px] bg-foreground" />49 {children}50 </DrawerPrimitive.Content>51 </DrawerPortal>52))53DrawerContent.displayName = 'DrawerContent'5455const DrawerHeader = ({56 className,57 ...props58}: React.HTMLAttributes<HTMLDivElement>) => (59 <div60 className={cn('grid gap-1.5 p-4 text-center sm:text-left', className)}61 {...props}62 />63)64DrawerHeader.displayName = 'DrawerHeader'6566const DrawerFooter = ({67 className,68 ...props69}: React.HTMLAttributes<HTMLDivElement>) => (70 <div71 className={cn('mt-auto flex flex-col gap-2 p-4', className)}72 {...props}73 />74)75DrawerFooter.displayName = 'DrawerFooter'7677const DrawerTitle = React.forwardRef<78 React.ElementRef<typeof DrawerPrimitive.Title>,79 React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>80>(({ className, ...props }, ref) => (81 <DrawerPrimitive.Title82 ref={ref}83 className={cn('text-lg font-bold uppercase tracking-wide leading-none', className)}84 {...props}85 />86))87DrawerTitle.displayName = DrawerPrimitive.Title.displayName8889// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alertalert | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps |
