drawer
shadcn-solidjs/drawerFreeComponent
shadcn-solidjs publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-solidjs on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-solidjs.com/r/drawer.jsonSource
1import type {2 CloseProps,3 ContentProps,4 DescriptionProps,5 DynamicProps,6 LabelProps,7 OverlayProps,8 TriggerProps,9} from "@corvu/drawer";10import DrawerPrimitive from "@corvu/drawer";1112import { cn } from "~/lib/utils.ts";13import type { Component, ComponentProps, JSX, ValidComponent } from "solid-js";1415import { splitProps } from "solid-js";1617const Drawer = DrawerPrimitive;1819const DrawerPortal = DrawerPrimitive.Portal;2021const DrawerTrigger = <T extends ValidComponent = "button">(22 props: DynamicProps<T, TriggerProps<T>>,23) => {24 return (25 <DrawerPrimitive.Trigger26 data-slot="drawer-trigger"27 {...(props as TriggerProps)}28 />29 );30};3132const DrawerClose = <T extends ValidComponent = "button">(33 props: DynamicProps<T, CloseProps<T>>,34) => {35 return (36 <DrawerPrimitive.Close37 data-slot="drawer-close"38 {...(props as CloseProps)}39 />40 );41};4243type DrawerOverlayProps<T extends ValidComponent = "div"> = OverlayProps<T> & {44 class?: string;45};4647const DrawerOverlay = <T extends ValidComponent = "div">(48 props: DynamicProps<T, DrawerOverlayProps<T>>,49) => {50 const [local, rest] = splitProps(props as DrawerOverlayProps, [51 "class",52 "style",53 ]);54 const drawerContext = DrawerPrimitive.useContext();55 return (56 <DrawerPrimitive.Overlay57 data-slot="drawer-overlay"58 class={cn(59 "bg-black/10 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 z-50 data-transitioning:transition-opacity data-transitioning:duration-300",60 props.class,61 )}62 // the drag/close fade rides on opacity, so a consumer style has to merge63 // with it rather than replace it64 style={typeof local.style === "string"65 ? `opacity:${drawerContext.openPercentage()};${local.style}`66 : { opacity: drawerContext.openPercentage(), ...local.style }}67 {...rest}68 />69 );70};7172type DrawerContentProps<T extends ValidComponent = "div"> = ContentProps<T> & {73 class?: string;74 children?: JSX.Element;75};7677const DrawerContent = <T extends ValidComponent = "div">(78 props: DynamicProps<T, DrawerContentProps<T>>,79) => {80 const [, rest] = splitProps(props as DrawerContentProps, [81 "class",82 "children",83 ]);84 return (85 <DrawerPortal>86 <DrawerOverlay />87 <DrawerPrimitive.Content88 data-slot="drawer-content"89 class={cn(90// … truncated
What it pulls in
npm packages
More from shadcn-solidjs
All 85 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn-solidjs | Components | Free | 1 dep | |
| alertalert | shadcn-solidjs | Components | Free | 2 deps | |
| alert-dialogalert-dialog | shadcn-solidjs | Components | Free | 2 deps | |
| aspect-ratioaspect-ratio | shadcn-solidjs | Components | Free | no deps | |
| attachmentattachment | shadcn-solidjs | Components | Free | 2 deps | |
| avataravatar | shadcn-solidjs | Components | Free | 1 dep | |
| badgebadge | shadcn-solidjs | Components | Free | 2 deps | |
| breadcrumbbreadcrumb | shadcn-solidjs | Components | Free | 1 dep |
