Sheet
solid-ui/sheetFreeComponent
A sheet component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/sheet.jsonSource
1import type { Component, ComponentProps, JSX, ValidComponent } from "solid-js"2import { splitProps } from "solid-js"34import * as SheetPrimitive from "@kobalte/core/dialog"5import type { PolymorphicProps } from "@kobalte/core/polymorphic"6import { cva, type VariantProps } from "class-variance-authority"78import { cn } from "~/lib/utils"910const Sheet = SheetPrimitive.Root11const SheetTrigger = SheetPrimitive.Trigger12const SheetClose = SheetPrimitive.CloseButton1314const portalVariants = cva("fixed inset-0 z-50 flex", {15 variants: {16 position: {17 top: "items-start",18 bottom: "items-end",19 left: "justify-start",20 right: "justify-end"21 }22 },23 defaultVariants: { position: "right" }24})2526type PortalProps = SheetPrimitive.DialogPortalProps & VariantProps<typeof portalVariants>2728const SheetPortal: Component<PortalProps> = (props) => {29 const [local, others] = splitProps(props, ["position", "children"])30 return (31 <SheetPrimitive.Portal {...others}>32 <div class={portalVariants({ position: local.position })}>{local.children}</div>33 </SheetPrimitive.Portal>34 )35}3637type DialogOverlayProps<T extends ValidComponent = "div"> = SheetPrimitive.DialogOverlayProps<T> & {38 class?: string | undefined39}4041const SheetOverlay = <T extends ValidComponent = "div">(42 props: PolymorphicProps<T, DialogOverlayProps<T>>43) => {44 const [local, others] = splitProps(props as DialogOverlayProps, ["class"])45 return (46 <SheetPrimitive.Overlay47 class={cn(48 "fixed inset-0 z-50 bg-black/80 data-[expanded=]:animate-in data-[closed=]:animate-out data-[closed=]:fade-out-0 data-[expanded=]:fade-in-0",49 local.class50 )}51 {...others}52 />53 )54}5556const sheetVariants = cva(57 "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[closed=]:duration-300 data-[expanded=]:duration-500 data-[expanded=]:animate-in data-[closed=]:animate-out",58 {59 variants: {60 position: {61 top: "inset-x-0 top-0 border-b data-[closed=]:slide-out-to-top data-[expanded=]:slide-in-from-top",62 bottom:63 "inset-x-0 bottom-0 border-t data-[closed=]:slide-out-to-bottom data-[expanded=]:slide-in-from-bottom",64 left: "inset-y-0 left-0 h-full w-3/4 border-r data-[closed=]:slide-out-to-left data-[expanded=]:slide-in-from-left sm:max-w-sm",65 right:66 "inset-y-0 right-0 h-full w-3/4 border-l data-[closed=]:slide-out-to-right data-[expanded=]:slide-in-from-right sm:max-w-sm"67 }68 },69// … truncated
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
