Sheet
Sheet with thoughtful defaults, semantic styling, and editable source.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/sheet.jsonUse it
Scroll horizontally for long lines
"use client";
import { useState } from "react";
import { Sheet } from "@/components/jez-ui/ui/sheet";
import { Button } from "@/components/jez-ui/ui/button";
import { FormField } from "@/components/jez-ui/ui/form-field";
import { Input } from "@/components/jez-ui/ui/input";
import { Select } from "@/components/jez-ui/ui/select";
import { Textarea } from "@/components/jez-ui/ui/textarea";
export default function Example() {
const [notice, setNotice] = useState("");
return (
<>
<Sheet
trigger={<Button variant="outline">Open details</Button>}
title="Project details"
description="Website refresh · PRJ-102"
>
<div className="grid gap-6">
<FormField label="Project name">
<Input defaultValue="Website refresh" />
</FormField>
<FormField label="Status">
<Select
label="Status"
defaultValue="progress"
options={[
{ label: "In progress", value: "progress" },
{ label: "In review", value: "review" },
{ label: "Complete", value: "complete" },
]}
/>
</FormField>
<FormField label="Notes">
<Textarea defaultValue="Explore a clearer homepage direction and bring the component previews up to date." />
</FormField>
<Button onClick={() => setNotice("Project details saved.")}>
Save changes
</Button>
</div>
</Sheet>
<p role="status">{notice}</p>
</>
);
}
Compose your own
These styled parts are included in the same install. Use children to build your layout; add className only when you want an override.
Scroll horizontally for long lines
import { Sheet, SheetTrigger, SheetPortal, SheetClose, SheetOverlay, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from "@/components/jez-ui/ui/sheet";Props & types
Scroll horizontally for long lines
React.ComponentProps<typeof P.Root> & {
trigger?: React.ReactNode;
title?: React.ReactNode;
description?: React.ReactNode;
className?: string;
closeLabel?: string;
cancelLabel?: string;
confirmLabel?: string;
}Source
View 2 source files
registry/ui/sheet.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Dialog as P } from "radix-ui";
import { X } from "lucide-react";
import { cn } from "./utils";
export function Sheet({
trigger,
title,
description,
children,
className,
closeLabel = "Close",
...props
}: React.ComponentProps<typeof P.Root> & {
trigger?: React.ReactNode;
title?: React.ReactNode;
description?: React.ReactNode;
className?: string;
closeLabel?: string;
cancelLabel?: string;
confirmLabel?: string;
}) {
return (
<P.Root {...props}>
{trigger !== undefined ? (
<>
<SheetTrigger asChild>{trigger}</SheetTrigger>
<SheetContent closeLabel={closeLabel} className={className}>
<SheetHeader>
<SheetTitle>{title}</SheetTitle>
<SheetDescription>{description}</SheetDescription>
</SheetHeader>
{children}
</SheetContent>
</>
) : (
children
)}
</P.Root>
);
}
export const SheetTrigger = P.Trigger;
export const SheetPortal = P.Portal;
export const SheetClose = P.Close;
export function SheetOverlay({
className,
...props
}: React.ComponentProps<typeof P.Overlay>) {
return (
<P.Overlay
className={cn("jez-overlay fixed inset-0 z-50 bg-black/40", className)}
{...props}
/>
);
}
export function SheetContent({
className,
children,
showClose = true,
closeLabel = "Close",
...props
}: React.ComponentProps<typeof P.Content> & {
showClose?: boolean;
closeLabel?: string;
}) {
return (
<P.Portal>
<SheetOverlay />
<P.Content
className={cn(
"jez-sheet fixed inset-y-0 right-0 z-50 flex h-dvh w-[min(94vw,460px)] flex-col overflow-y-auto bg-background p-6 text-foreground shadow-2xl",
className,
)}
{...props}
>
{children}
{showClose && (
<P.Close
aria-label={closeLabel}
className="absolute right-4 top-4 grid size-8 place-items-center rounded-md text-muted-foreground hover:bg-muted"
>
<X size={16} />
</P.Close>
)}
</P.Content>
</P.Portal>
);
}
export function SheetHeader({
className,
...props
}: React.ComponentProps<"div">) {
return <div className={cn("mb-6 grid gap-2 pr-8", className)} {...props} />;
}
export function SheetFooter({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
className={cn("mt-6 flex flex-wrap justify-end gap-3", className)}
{...props}
/>
);
}
export function SheetTitle({
className,
...props
}: React.ComponentProps<typeof P.Title>) {
return (
<P.Title
className={cn(
"font-display text-xl font-semibold tracking-tight",
className,
)}
{...props}
/>
);
}
export function SheetDescription({
className,
...props
}: React.ComponentProps<typeof P.Description>) {
return (
<P.Description
className={cn("text-sm leading-relaxed text-muted-foreground", className)}
{...props}
/>
);
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
Dependencies
radix-ui@1.6.7 · lucide-react@0.577.0 · clsx@2.1.1 · tailwind-merge@3.5.0
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →