Drawer
optics/drawerFreeComponent
A drawer component built with Vaul.
See it running
Open the demo on optics
optics.agusmayol.com.ar/components/drawerInstall it
npx shadcn@latest add https://optics.agusmayol.com.ar/r/drawer.jsonSource
1"use client";23import * as React from "react";4import { Drawer as DrawerPrimitive } from "vaul-base";56import { cn } from "@/lib/utils";78function Drawer({ ...props } = {}) {9 return <DrawerPrimitive.Root data-slot="drawer" {...props} />;10}1112function DrawerTrigger({ ...props } = {}) {13 return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />;14}1516function DrawerPortal({ ...props } = {}) {17 return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />;18}1920function DrawerClose({ ...props } = {}) {21 return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;22}2324function DrawerOverlay({ className = "", ...props }) {25 return (26 <DrawerPrimitive.Overlay27 data-slot="drawer-overlay"28 className={cn(29 "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 z-50",30 className,31 )}32 {...props}33 />34 );35}3637function DrawerHandle({ className = "", ...props }) {38 return (39 <DrawerPrimitive.Handle40 data-slot="drawer-handle"41 className={cn(42 "mx-auto mt-4 h-1.5 w-[100px] rounded-full bg-muted",43 className,44 )}45 {...props}46 />47 );48}4950function DrawerContent({ className = "", children = null, ...props }) {51 return (52 <DrawerPortal data-slot="drawer-portal">53 <DrawerOverlay />54 <DrawerPrimitive.Content55 data-slot="drawer-content"56 className={cn(57 "before:bg-background flex h-auto flex-col bg-transparent p-2 text-xs/relaxed before:absolute before:inset-2 before:-z-10 before:rounded-xl data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=left]:sm:max-w-sm data-[vaul-drawer-direction=right]:sm:max-w-sm group/drawer-content fixed z-50",58 className,59 )}60 {...props}61 >62 <DrawerHandle className="group-data-[vaul-drawer-direction=bottom]/drawer-content:block hidden shrink-0" />63 {children}64 </DrawerPrimitive.Content>65// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from optics
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | optics | Components | Free | 5 deps | |
| Alertalert | optics | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | optics | Components | Free | 4 deps | |
| Aspect Ratioaspect-ratio | optics | Components | Free | 2 deps | |
| Auto Heightauto-height | optics | Components | Free | 3 deps | |
| Avataravatar | optics | Components | Free | 3 deps | |
| Badgebadge | optics | Components | Free | 4 deps | |
| Breadcrumbbreadcrumb | optics | Components | Free | 4 deps |
