Sheet
⋯
Sheet is a right-side modal panel built on Base UI Dialog. Add your own header controls, content, and actions inside it.
Import Sheet from @nesra/ui/sheet or the package root.
import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetMinimalExample() { return ( <Sheet> <Sheet.Trigger render={<Button variant="outline" />}>Open sheet</Sheet.Trigger> <Sheet.Content> <Sheet.Header className="flex-row items-start justify-between"> <div> <Sheet.Title>Project details</Sheet.Title> <Sheet.Description>Review the selected project.</Sheet.Description> </div> <Sheet.Close /> </Sheet.Header> <p className="px-nesra-spacing-xl sm:px-nesra-spacing-3xl"> The project is ready for review. </p> </Sheet.Content> </Sheet> );}Composition
Section titled “Composition”Sheet├─ Sheet.Trigger└─ Sheet.Content ├─ Sheet.Header │ ├─ Sheet.Title │ ├─ Sheet.Description (optional) │ └─ Sheet.Close ├─ your content └─ Sheet.Footer (optional)Sheet.Content creates the portal and a dimmed, blurred backdrop. It slides in from the right with a default width of 400px and a maximum width of the viewport minus 24px. Motion is disabled when the user prefers reduced motion. The panel scrolls when its contents exceed the viewport; Sheet.Header stays visible at the top. Set className on Sheet.Content for another width, such as w-[928px].
Examples
Section titled “Examples”With actions
Section titled “With actions”Compose application state and footer buttons. The example applies the current query when the user chooses Apply filter.
import { useState } from "react";import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetBasicExample() { const [query, setQuery] = useState(""); const [appliedQuery, setAppliedQuery] = useState("");
return ( <div> <Sheet> <Sheet.Trigger render={<Button variant="outline" />}>Open filters</Sheet.Trigger> <Sheet.Content> <Sheet.Header className="flex-row items-start"> <div className="min-w-0 flex-1"> <Sheet.Title>Filters</Sheet.Title> <Sheet.Description>Add filters to narrow down results.</Sheet.Description> </div> <Sheet.Close /> </Sheet.Header> <div className="px-nesra-spacing-xl pb-nesra-spacing-3xl sm:px-nesra-spacing-3xl"> <label className="type-nesra-body-small-medium" htmlFor="sheet-query"> Search term </label> <input className="mt-nesra-spacing-md w-full rounded-nesra-sm border border-nesra-stroke-border p-nesra-spacing-md" id="sheet-query" onChange={(event) => setQuery(event.target.value)} value={query} /> </div> <Sheet.Footer> <Button onClick={() => setQuery("")} size="sm" variant="outline"> Clear </Button> <Sheet.Close onClick={() => setAppliedQuery(query)} render={<Button size="sm" />}> Apply filter </Sheet.Close> </Sheet.Footer> </Sheet.Content> </Sheet> <p className="mt-nesra-spacing-xl type-nesra-body-small-regular"> Applied: {appliedQuery || "none"} </p> </div> );}Compact header
Section titled “Compact header”size="compact" renders the form sheet header from the Finance Master Data designs. Place Sheet.Title, Sheet.Description, and an icon-only Sheet.Close directly inside Sheet.Header.
| Detail | default |
compact |
|---|---|---|
| Padding | 16px; 24px from sm |
24px inline, 16px block |
| Gap between children | 8px | 4px |
| Bottom divider | border-nesra-stroke-divider |
None |
Title from sm |
type-nesra-body-large-semibold |
type-nesra-body-medium-semibold |
Icon-only Sheet.Close box |
36px, in the header’s flow | 24px, pinned 16px from the top and 24px from the end |
| End padding with close | Set by your layout | 68px when Sheet.Close is a direct child, leaving 20px before the close |
import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetCompactHeaderExample() { return ( <Sheet> <Sheet.Trigger render={<Button variant="outline" />}>Add employee</Sheet.Trigger> <Sheet.Content className="w-[720px]"> <Sheet.Header size="compact"> <Sheet.Title>Add new employee</Sheet.Title> <Sheet.Description>Complete the form to start the onboarding process.</Sheet.Description> <Sheet.Close /> </Sheet.Header> <div className="flex flex-col gap-nesra-spacing-md px-nesra-padding-4xl py-nesra-padding-2xl"> <label className="type-nesra-body-small-medium" htmlFor="sheet-employee-name"> Full name </label> <input className="rounded-nesra-sm border border-nesra-stroke-border p-nesra-spacing-md" id="sheet-employee-name" /> </div> <Sheet.Footer> <Sheet.Close render={<Button variant="outline" />}>Cancel</Sheet.Close> <Button>Save</Button> </Sheet.Footer> </Sheet.Content> </Sheet> );}Wide content
Section titled “Wide content”The Ads comparison design uses a 928px panel with a two-row header and no footer. The table in this example is application content.
import { useState } from "react";import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetWideExample() { const [period, setPeriod] = useState<"monthly" | "weekly">("monthly");
return ( <Sheet> <Sheet.Trigger render={<Button variant="outline" />}>Compare metrics</Sheet.Trigger> <Sheet.Content className="w-[928px]"> <Sheet.Header className="border-b border-nesra-stroke-border"> <div className="flex items-center justify-between"> <Sheet.Title>Compare: Conversions</Sheet.Title> <Sheet.Close /> </div> <div className="flex gap-nesra-spacing-md"> <Button size="sm" variant={period === "monthly" ? "primary" : "outline"} aria-pressed={period === "monthly"} onClick={() => setPeriod("monthly")} > Monthly </Button> <Button size="sm" variant={period === "weekly" ? "primary" : "outline"} aria-pressed={period === "weekly"} onClick={() => setPeriod("weekly")} > Weekly </Button> </div> </Sheet.Header> <div className="overflow-x-auto p-nesra-spacing-xl sm:p-nesra-spacing-3xl"> <table className="w-full min-w-[520px] border-collapse text-left type-nesra-body-small-regular"> <thead> <tr className="border-b border-nesra-stroke-divider"> <th className="p-nesra-spacing-md">Metric</th> <th className="p-nesra-spacing-md">{period === "monthly" ? "July" : "Week 1"}</th> <th className="p-nesra-spacing-md">{period === "monthly" ? "August" : "Week 2"}</th> </tr> </thead> <tbody> <tr> <td className="p-nesra-spacing-md">Conversions</td> <td className="p-nesra-spacing-md">{period === "monthly" ? "1,200" : "300"}</td> <td className="p-nesra-spacing-md">{period === "monthly" ? "1,480" : "370"}</td> </tr> </tbody> </table> </div> </Sheet.Content> </Sheet> );}Long content
Section titled “Long content”The panel scrolls vertically when content exceeds the viewport height. Its header stays visible while scrolling.
import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetLongContentExample() { return ( <Sheet> <Sheet.Trigger render={<Button variant="outline" />}>Review activity</Sheet.Trigger> <Sheet.Content> <Sheet.Header className="flex-row items-center justify-between"> <Sheet.Title>Recent activity</Sheet.Title> <Sheet.Close /> </Sheet.Header> <div className="px-nesra-spacing-xl sm:px-nesra-spacing-3xl"> {Array.from({ length: 30 }, (_, index) => ( <p className="border-b border-nesra-stroke-divider py-nesra-spacing-lg" key={index}> Activity {index + 1} </p> ))} </div> </Sheet.Content> </Sheet> );}Controlled open state
Section titled “Controlled open state”Pass open and onOpenChange when the application needs to observe or change disclosure from outside the sheet.
import { useState } from "react";import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetControlledExample() { const [open, setOpen] = useState(false);
return ( <div> <Button onClick={() => setOpen(true)} variant="outline"> Open controlled sheet </Button> <p className="mt-nesra-spacing-xl type-nesra-body-small-regular"> State: {open ? "open" : "closed"} </p> <Sheet onOpenChange={setOpen} open={open}> <Sheet.Content> <Sheet.Header className="flex-row items-start justify-between"> <div> <Sheet.Title>Controlled sheet</Sheet.Title> <Sheet.Description>The application owns the open state.</Sheet.Description> </div> <Sheet.Close /> </Sheet.Header> <div className="px-nesra-spacing-xl sm:px-nesra-spacing-3xl"> <Button onClick={() => setOpen(false)} variant="outline"> Close from state </Button> </div> </Sheet.Content> </Sheet> </div> );}Form and initial focus
Section titled “Form and initial focus”initialFocus targets the name field. The application validates, saves, and closes after submission; Cancel closes without saving.
import { useRef, useState, type SyntheticEvent } from "react";import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetFormExample() { const [open, setOpen] = useState(false); const [name, setName] = useState(""); const [savedName, setSavedName] = useState(""); const nameRef = useRef<HTMLInputElement>(null);
function save(event: SyntheticEvent<HTMLFormElement, SubmitEvent>) { event.preventDefault(); setSavedName(name.trim()); setOpen(false); }
return ( <div> <Sheet onOpenChange={setOpen} open={open}> <Sheet.Trigger render={<Button variant="outline" />}>Edit project</Sheet.Trigger> <Sheet.Content initialFocus={nameRef}> <Sheet.Header className="flex-row items-start justify-between"> <div> <Sheet.Title>Edit project</Sheet.Title> <Sheet.Description>Change the project name and save it.</Sheet.Description> </div> <Sheet.Close /> </Sheet.Header> <form onSubmit={save}> <div className="px-nesra-spacing-xl sm:px-nesra-spacing-3xl"> <label className="type-nesra-body-small-medium" htmlFor="sheet-project-name"> Project name </label> <input className="mt-nesra-spacing-md w-full rounded-nesra-sm border border-nesra-stroke-border p-nesra-spacing-md" id="sheet-project-name" onChange={(event) => setName(event.target.value)} ref={nameRef} required value={name} /> </div> <Sheet.Footer> <Sheet.Close render={<Button type="button" variant="outline" />}>Cancel</Sheet.Close> <Button type="submit">Save</Button> </Sheet.Footer> </form> </Sheet.Content> </Sheet> <p className="mt-nesra-spacing-xl type-nesra-body-small-regular"> Saved project: {savedName || "none"} </p> </div> );}Outside press disabled
Section titled “Outside press disabled”disablePointerDismissal prevents a backdrop press from closing the sheet. Escape and the close controls still work.
import { Button } from "@nesra/ui/button";import { Sheet } from "@nesra/ui/sheet";
export function SheetDisableOutsidePressExample() { return ( <Sheet disablePointerDismissal> <Sheet.Trigger render={<Button variant="outline" />}>Open review sheet</Sheet.Trigger> <Sheet.Content> <Sheet.Header className="flex-row items-start justify-between"> <div> <Sheet.Title>Review changes</Sheet.Title> <Sheet.Description>Use a button to finish or dismiss this review.</Sheet.Description> </div> <Sheet.Close /> </Sheet.Header> <Sheet.Footer> <Sheet.Close render={<Button variant="outline" />}>Done</Sheet.Close> </Sheet.Footer> </Sheet.Content> </Sheet> );}Nested dropdown menu
Section titled “Nested dropdown menu”Place other interactive primitives inside the sheet. The dropdown selection stays in application state.
import { useState } from "react";import { Button } from "@nesra/ui/button";import { DropdownMenu } from "@nesra/ui/dropdown-menu";import { Sheet } from "@nesra/ui/sheet";
export function SheetNestedMenuExample() { const [selection, setSelection] = useState("None");
return ( <Sheet> <Sheet.Trigger render={<Button variant="outline" />}>Open actions</Sheet.Trigger> <Sheet.Content> <Sheet.Header className="flex-row items-start justify-between"> <div> <Sheet.Title>Document actions</Sheet.Title> <Sheet.Description>Choose an action for this document.</Sheet.Description> </div> <Sheet.Close /> </Sheet.Header> <div className="px-nesra-spacing-xl sm:px-nesra-spacing-3xl"> <DropdownMenu> <DropdownMenu.Trigger render={<Button variant="outline" />}> Actions </DropdownMenu.Trigger> <DropdownMenu.Content align="start"> <DropdownMenu.Item onClick={() => setSelection("Duplicate")}> Duplicate </DropdownMenu.Item> <DropdownMenu.Item onClick={() => setSelection("Archive")}>Archive</DropdownMenu.Item> </DropdownMenu.Content> </DropdownMenu> <p className="mt-nesra-spacing-xl type-nesra-body-small-regular">Selected: {selection}</p> </div> </Sheet.Content> </Sheet> );}Design reference
Section titled “Design reference”The Filters slideout menu in Figma uses a 400px panel for filter controls. The Ads comparison sheet uses a 928px panel with a two-row header and table, without a footer. Both open from the right. Content and width belong to each use case; neither set of fields is part of the Sheet API.
Light and Dark
Section titled “Light and Dark”The backdrop matches the Figma Filters slideout: --nesra-foundation-bg-overlay at 70% opacity with
backdrop-blur-nesra-md (16px). The overlay is near-black in both modes, so the page behind the
sheet dims in Dark as well as Light. The panel, header, and footer use
--nesra-surface-card-bg-neutral; Sheet.Description uses --nesra-text-support.
Accessibility
Section titled “Accessibility”Sheet.Titlenames the dialog. Include it for every sheet.Sheet.Descriptionsupplies optional supporting text.- Base UI Dialog traps focus, makes the rest of the page inert, locks page scrolling, and returns focus to the trigger after closing. Keyboard opening focuses the first focusable control. Pointer and touch opening focus the panel; a custom
initialFocusoverrides this behavior. - Escape, an outside press, or
Sheet.Closecloses the sheet. An icon-onlySheet.Closerenders an X with the accessible labelClose panel. Text or custom controls can be supplied through children orrender. - In a compact header, the icon-only close has a 24px visible box and a 40px pointer target, which exceeds the WCAG 2.5.8 minimum of 24 by 24 CSS pixels. Custom close controls keep their own size and position.
- The application owns form state, validation, and whether footer actions apply or discard changes. Use
openandonOpenChangefor a controlled sheet.
API reference
Section titled “API reference”| Part | Props | Effect |
|---|---|---|
Sheet |
Base UI Dialog root props, including open, defaultOpen, onOpenChange, modal |
Manages disclosure and focus. Modal by default. |
Sheet.Trigger |
Base UI Dialog trigger props | Opens the sheet. render composes an existing button. |
Sheet.Content |
Base UI Dialog popup props | Creates portal, backdrop, and right-side panel. className sets width. initialFocus and finalFocus can override focus targets. |
Sheet.Header |
Native div props, plus size: "default" (default) or "compact" |
Optional header region that stays visible while the panel scrolls. size sets header density, title type, and icon-only close. |
Sheet.Footer |
Native div props |
Optional footer region. |
Sheet.Title, Sheet.Description |
Base UI Dialog title and description props | Accessible name and description. |
Sheet.Close |
Base UI Dialog close props | Closes on activation. Defaults to an X icon and Close panel label. In a compact header, the icon-only close is pinned. |
The package also exports SheetHeaderSize ("default" | "compact") for wrappers that forward size.