-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathdrawer.tsx
31 lines (26 loc) · 961 Bytes
/
drawer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use client";
import { forwardRef } from "react";
import { Drawer as DrawerPrimitive } from "vaul";
import { cn } from "@/lib/utils";
const DrawerTrigger = DrawerPrimitive.Trigger;
const DrawerContent = forwardRef<
React.ElementRef<typeof DrawerPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DrawerPrimitive.Portal>
<DrawerPrimitive.Overlay className="fixed inset-0 z-50 bg-black/80" />
<DrawerPrimitive.Content
ref={ref}
className={cn(
"fixed inset-x-0 bottom-0 z-50 mt-24 h-[96%] rounded-t-[10px] bg-background",
className,
)}
{...props}
>
<div className="absolute left-1/2 top-3 h-2 w-[100px] translate-x-[-50%] rounded-full bg-muted" />
{children}
</DrawerPrimitive.Content>
</DrawerPrimitive.Portal>
));
DrawerContent.displayName = "DrawerContent";
export { DrawerContent, DrawerTrigger };