Sheet

Web/Mobile

Extends the Dialog to display content that complements the main content of the screen.

Installation

pnpm dlx cubix-ui@latest add sheet --base radix

Usage

Import
import { Button } from "@/components/cubix/button"
import { TextField, TextFieldInput, TextFieldLabel } from "@/components/cubix/text-field"
import {
  Sheet,
  SheetClose,
  SheetContent,

  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@/components/cubix/sheet"
Example
<Sheet>
  <SheetTrigger render={<Button variant="outline" size="sm" />}>ویرایش پروفایل</SheetTrigger>
  <SheetContent>
    <SheetHeader>
      <SheetTitle>ویرایش پروفایل</SheetTitle>
</SheetHeader>
    <div className="grid gap-4 px-4">
      <TextField>
        <TextFieldLabel>نام و نام خانوادگی</TextFieldLabel>
        <TextFieldInput placeholder="امین ابدالی" />
      </TextField>
      <TextField>
        <TextFieldLabel>نام کاربری</TextFieldLabel>
        <TextFieldInput placeholder="@amin" />
      </TextField>
    </div>
    <SheetFooter>
      <Button type="submit">
        ذخیره تغییرات
      </Button>
      <SheetClose render={<Button variant="outline" />}>بستن</SheetClose>
    </SheetFooter>
  </SheetContent>
</Sheet>

Composition

Use the following composition to build a Sheet:

 
Sheet
├── SheetTrigger
└── SheetContent
    ├── SheetHeader
    │   ├── SheetTitle
    │   └── SheetDescription
    ├── …content
    └── SheetFooter
        ├── Button
        └── SheetClose

Examples

Side

Use the side prop on SheetContent to set the edge of the screen where the sheet appears. Values are top, right, bottom, or left.

Custom styling

Pass className on SheetHeader and SheetFooter to drop the divider lines and muted footer background.

Without built-in close

Set showCloseButton={false} on SheetContent to hide the built-in X button and provide your own.

API Reference

Note: Sheet is built on the Dialog primitive. It moves focus to its panel when it opens, traps focus, and dismisses on Escape or backdrop click. Use the same props on Base UI, React Aria, and Radix.

Sheet

The container that wraps the trigger and content and manages open state.

PropTypeDefaultDescription
openboolean-Controlled open state. Omit to use uncontrolled mode.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void-Called when the open state changes.
childrenReact.ReactNode-The trigger and sheet content.

SheetTrigger / SheetClose

The elements that open and close the sheet. Compose both with Cubix Button via render.

PropTypeDefaultDescription
renderReact.ReactElement-Render the trigger or close control as another Cubix element (e.g. a Button).
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

SheetContent

The sliding panel rendered with a backdrop.

PropTypeDefaultDescription
side"top" | "right" | "bottom" | "left""right"Edge of the screen where the sheet appears.
showCloseButtonbooleantrueShow the built-in close (X) button in the top end corner.
dir"ltr" | "rtl""rtl"Text direction of the portaled panel. Defaults to RTL for Persian-first layouts.
langstring"fa"Language attribute applied when dir is "rtl". Pass dir="ltr" to omit it.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

SheetHeader / SheetFooter

Layout regions of the sheet content.

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

SheetTitle / SheetDescription

The title and supporting text of the sheet.

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).