# Sheet

import { Callout } from "fumadocs-ui/components/callout";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Tabs, Tab } from "fumadocs-ui/components/tabs";
import {
  Badge,
  Button,
  Card,
  CardContent,
  CardHeader,
  CardTitle,
  Input,
  Sheet,
  SheetClose,
  SheetContent,
  SheetDescription,
  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@pycolors/ui";
import {
  Filter,
  FormInput,
  Layers3,
  ListFilter,
  Menu,
  MousePointerClick,
  PanelLeft,
  PanelTop,
  PencilLine,
} from "lucide-react";
import { PreferAvoid } from "@/components/docs/prefer-avoid";
import { DocsLinks } from "@/components/docs/docs-links";
import { DocsFeatureGrid } from "@/components/docs/docs-feature-grid";
import { DocsConceptTabs } from "@/components/docs/docs-concept-tabs";

<div className="flex flex-wrap items-center gap-2">
  <Badge variant="outline">
    UI
  </Badge>

  <Badge>
    Sheet
  </Badge>
</div>

## Side workflows without leaving context

The **Sheet** component is a slide-over panel used for side workflows, filters, navigation, and contextual editing.

Use it for:

* advanced filters
* mobile navigation
* side editing panels
* detail panels
* contextual settings
* secondary workflows that should preserve page context

Sheet is built on **Radix Dialog** and styled with PyColors semantic tokens such as `bg-card`, `border-border`, and `text-foreground`.

<Callout title="Core idea">
  Sheet keeps the user in context while exposing a larger secondary workflow.
</Callout>

### Import

```tsx title="sheet-import.tsx"
import {
  Sheet,
  SheetClose,
  SheetContent,
  SheetDescription,
  SheetFooter,
  SheetHeader,
  SheetTitle,
  SheetTrigger,
} from "@pycolors/ui";
```

### Basic usage

Use Sheet for a side panel that contains a focused but larger workflow than a Dialog.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <Sheet>
        <SheetTrigger asChild>
          <Button variant="outline">
            Open sheet
          </Button>
        </SheetTrigger>

        <SheetContent side="right" className="w-[380px] sm:w-[420px]">
          <SheetHeader>
            <SheetTitle>
              Edit profile
            </SheetTitle>

            <SheetDescription>
              {"Update your account details. Changes are saved on submit."}
            </SheetDescription>
          </SheetHeader>

          <div className="mt-6 grid gap-3">
            <Input label="Name" placeholder="Patrice" />

            <Input label="Email" placeholder="you@domain.com" />

            <Input label="Company" placeholder="PyColors" autoComplete="organization" />
          </div>

          <SheetFooter className="mt-6">
            <SheetClose asChild>
              <Button variant="secondary">
                Cancel
              </Button>
            </SheetClose>

            <Button>
              Save
            </Button>
          </SheetFooter>
        </SheetContent>
      </Sheet>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="profile-sheet.tsx"
    "use client";

    import {
      Button,
      Input,
      Sheet,
      SheetClose,
      SheetContent,
      SheetDescription,
      SheetFooter,
      SheetHeader,
      SheetTitle,
      SheetTrigger,
    } from "@pycolors/ui";

    export function ProfileSheet() {
      return (
        <Sheet>
          <SheetTrigger asChild>
            <Button variant="outline">Open sheet</Button>
          </SheetTrigger>

          <SheetContent side="right" className="w-[380px] sm:w-[420px]">
            <SheetHeader>
              <SheetTitle>Edit profile</SheetTitle>
              <SheetDescription>
                Update your account details. Changes are saved on submit.
              </SheetDescription>
            </SheetHeader>

            <div className="mt-6 grid gap-3">
              <Input label="Name" placeholder="Patrice" />
              <Input label="Email" placeholder="you@domain.com" />
              <Input label="Company" placeholder="PyColors" autoComplete="organization" />
            </div>

            <SheetFooter className="mt-6">
              <SheetClose asChild>
                <Button variant="secondary">Cancel</Button>
              </SheetClose>
              <Button>Save</Button>
            </SheetFooter>
          </SheetContent>
        </Sheet>
      );
    }
    ```
  </Tab>
</Tabs>

<Callout type="info" title="Trigger rule">
  Prefer `SheetTrigger asChild` so the trigger keeps the semantics of the element you pass, such as a real Button.
</Callout>

## When to use Sheet

Use Sheet when the user needs more space than a menu, but should keep page context.

<DocsFeatureGrid
  columns={3}
  tone="platform"
  items={[
  {
    title: 'Filters',
    description:
      'Use for advanced filters without crowding the toolbar.',
    icon: ListFilter,
  },
  {
    title: 'Side editing',
    description:
      'Use for editing records while keeping the parent page visible.',
    icon: PencilLine,
  },
  {
    title: 'Mobile navigation',
    description:
      'Use a left sheet for mobile menus and app navigation.',
    icon: Menu,
  },
]}
/>

### Sides

Sheets support four placement options through the `side` prop.

Use the placement to match the mental model of the workflow.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <div className="flex flex-wrap gap-2">
        <Sheet>
          <SheetTrigger asChild>
            <Button variant="outline">
              Right
            </Button>
          </SheetTrigger>

          <SheetContent side="right">
            <SheetHeader>
              <SheetTitle>
                Right sheet
              </SheetTitle>

              <SheetDescription>
                {"Default placement for editing and details."}
              </SheetDescription>
            </SheetHeader>
          </SheetContent>
        </Sheet>

        <Sheet>
          <SheetTrigger asChild>
            <Button variant="outline">
              Left
            </Button>
          </SheetTrigger>

          <SheetContent side="left">
            <SheetHeader>
              <SheetTitle>
                Left sheet
              </SheetTitle>

              <SheetDescription>
                {"Recommended for navigation."}
              </SheetDescription>
            </SheetHeader>
          </SheetContent>
        </Sheet>

        <Sheet>
          <SheetTrigger asChild>
            <Button variant="outline">
              Top
            </Button>
          </SheetTrigger>

          <SheetContent side="top">
            <SheetHeader>
              <SheetTitle>
                Top sheet
              </SheetTitle>

              <SheetDescription>
                {"Useful for compact global controls."}
              </SheetDescription>
            </SheetHeader>
          </SheetContent>
        </Sheet>

        <Sheet>
          <SheetTrigger asChild>
            <Button variant="outline">
              Bottom
            </Button>
          </SheetTrigger>

          <SheetContent side="bottom">
            <SheetHeader>
              <SheetTitle>
                Bottom sheet
              </SheetTitle>

              <SheetDescription>
                {"Useful for mobile-first actions."}
              </SheetDescription>
            </SheetHeader>
          </SheetContent>
        </Sheet>
      </div>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="sheet-sides.tsx"
    import {
      Button,
      Sheet,
      SheetContent,
      SheetDescription,
      SheetHeader,
      SheetTitle,
      SheetTrigger,
    } from "@pycolors/ui";

    export function SheetSides() {
      return (
        <div className="flex flex-wrap gap-2">
          <Sheet>
            <SheetTrigger asChild>
              <Button variant="outline">Right</Button>
            </SheetTrigger>
            <SheetContent side="right">
              <SheetHeader>
                <SheetTitle>Right sheet</SheetTitle>
                <SheetDescription>
                  Default placement for editing and details.
                </SheetDescription>
              </SheetHeader>
            </SheetContent>
          </Sheet>

          <Sheet>
            <SheetTrigger asChild>
              <Button variant="outline">Left</Button>
            </SheetTrigger>
            <SheetContent side="left">
              <SheetHeader>
                <SheetTitle>Left sheet</SheetTitle>
                <SheetDescription>
                  Recommended for navigation.
                </SheetDescription>
              </SheetHeader>
            </SheetContent>
          </Sheet>
        </div>
      );
    }
    ```
  </Tab>
</Tabs>

### Placement guidance

| Side     | Best for                                        |
| -------- | ----------------------------------------------- |
| `right`  | Editing, details, contextual panels             |
| `left`   | Navigation, app menu, mobile sidebar            |
| `top`    | Global filters, announcements, compact controls |
| `bottom` | Mobile-first actions, quick controls            |

<Callout title="Placement rule">
  Use `right` for editing, `left` for navigation, and `bottom` for mobile-first action panels.
</Callout>

### Close behavior

`SheetContent` includes a close button. Use `SheetClose` for explicit footer actions.

<Tabs items={["Preview", "Code"]}>
  <Tab value="Preview">
    <Preview>
      <Sheet>
        <SheetTrigger asChild>
          <Button variant="outline">
            Open
          </Button>
        </SheetTrigger>

        <SheetContent>
          <SheetHeader>
            <SheetTitle>
              Confirm
            </SheetTitle>

            <SheetDescription>
              {"Close with the button, the close control, or Escape."}
            </SheetDescription>
          </SheetHeader>

          <div className="mt-6 flex gap-2">
            <SheetClose asChild>
              <Button variant="secondary">
                Cancel
              </Button>
            </SheetClose>

            <SheetClose asChild>
              <Button>
                Done
              </Button>
            </SheetClose>
          </div>
        </SheetContent>
      </Sheet>
    </Preview>
  </Tab>

  <Tab value="Code">
    ```tsx title="sheet-close-actions.tsx"
    import {
      Button,
      Sheet,
      SheetClose,
      SheetContent,
      SheetDescription,
      SheetHeader,
      SheetTitle,
      SheetTrigger,
    } from "@pycolors/ui";

    export function SheetCloseActions() {
      return (
        <Sheet>
          <SheetTrigger asChild>
            <Button variant="outline">Open</Button>
          </SheetTrigger>

          <SheetContent>
            <SheetHeader>
              <SheetTitle>Confirm</SheetTitle>
              <SheetDescription>
                Close with the button, the close control, or Escape.
              </SheetDescription>
            </SheetHeader>

            <div className="mt-6 flex gap-2">
              <SheetClose asChild>
                <Button variant="secondary">Cancel</Button>
              </SheetClose>
              <SheetClose asChild>
                <Button>Done</Button>
              </SheetClose>
            </div>
          </SheetContent>
        </Sheet>
      );
    }
    ```
  </Tab>
</Tabs>

### Usage patterns

<Steps>
  <Step>
    #### Choose the right side

    Pick the placement based on the workflow: right for details, left for navigation, bottom for mobile actions.
  </Step>

  <Step>
    #### Keep the page context visible

    A sheet should extend the page, not replace it. Avoid using it for flows that need a full page.
  </Step>

  <Step>
    #### Provide title and description

    Use `SheetTitle` and `SheetDescription` so users understand the purpose of the panel.
  </Step>

  <Step>
    #### Use one primary action

    Most sheets should have one primary action and one secondary close or cancel action.
  </Step>

  <Step>
    #### Handle scroll intentionally

    Avoid nested scroll containers. Prefer one clear scrollable region inside the sheet.
  </Step>
</Steps>

## Sheet vs Dialog vs Dropdown Menu

| Situation                      | Use          |
| ------------------------------ | ------------ |
| Advanced filters               | Sheet        |
| Side editing panel             | Sheet        |
| Mobile navigation              | Sheet        |
| Record details panel           | Sheet        |
| Short destructive confirmation | Dialog       |
| Small contextual action list   | DropdownMenu |
| Full multi-step workflow       | Page         |

<Callout type="info" title="Decision rule">
  Sheet is for side workflows. Dialog is for focused decisions. Dropdown Menu is for compact choices.
</Callout>

## API

#### Component

| Component          | Description                              |
| ------------------ | ---------------------------------------- |
| `Sheet`            | Root container                           |
| `SheetTrigger`     | Trigger element, usually with `asChild`  |
| `SheetClose`       | Close control, usually wrapping a Button |
| `SheetContent`     | Slide-over panel surface                 |
| `SheetHeader`      | Title and description stack helper       |
| `SheetFooter`      | Action row helper                        |
| `SheetTitle`       | Accessible sheet title                   |
| `SheetDescription` | Supporting text                          |

#### SheetContent props

| Prop        | Type                            | Default   | Description                 |
| ----------- | ------------------------------- | --------- | --------------------------- |
| `side`      | `SheetSide`                     | `"right"` | Placement of the panel      |
| `className` | `string`                        | —         | Additional Tailwind classes |
| `...props`  | `DialogPrimitive.Content` props | —         | Radix Dialog Content props  |

`Sheet`, `SheetTrigger`, and `SheetClose` are re-exports of Radix Dialog primitives and accept their native props.

### TypeScript types

```ts title="sheet-types.ts"
export type SheetSide = "top" | "bottom" | "left" | "right";

export interface SheetContentProps
  extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
  side?: SheetSide;
}
```

### Accessibility

Sheet is built on Radix Dialog primitives.

That means:

* focus is trapped while open
* focus returns to the trigger on close
* Escape closes the sheet by default
* screen readers receive dialog semantics
* `SheetTitle` provides the accessible name

Guidelines:

* use `SheetTrigger asChild` with a semantic trigger
* include a clear `SheetTitle`
* include a useful `SheetDescription`
* avoid using Sheet for destructive confirmations
* avoid nested sheets
* avoid long multi-step flows inside a sheet

<Callout title="Accessibility rule">
  A sheet still behaves like a dialog. It needs clear labeling, focus management, and a bounded task.
</Callout>

## Prefer / avoid

<PreferAvoid
  prefer={[
  "right sheets for editing and details",
  "left sheets for navigation",
  "clear title and description",
  "one primary footer action",
  "one intentional scroll region",
]}
  avoid={[
  "destructive confirmations that should be dialogs",
  "full-page workflows squeezed into a panel",
  "nested sheets",
  "multiple competing primary actions",
  "unclear scrolling with nested containers",
]}
/>

### Product copy guidelines

Sheet copy should tell users what the panel does and what happens next.

<DocsConceptTabs
  items={[
  {
    value: 'Filters',
    title: 'Filter projects',
    icon: ListFilter,
    description: (
      <>
        <p>
          Filtering should reduce noise without overwhelming the interface.
        </p>

        <div className="mt-3 rounded-[5px] border border-border-subtle bg-muted/30 px-3 py-2 text-sm text-muted-foreground">
          Narrow results by status, owner, date, and plan.
        </div>
      </>
    ),
  },
  {
    value: 'Edit',
    title: 'Edit profile',
    icon: PencilLine,
    description: (
      <>
        <p>
          Side editing keeps the parent surface visible while updating focused data.
        </p>

        <div className="mt-3 rounded-[5px] border border-border-subtle bg-muted/30 px-3 py-2 text-sm text-muted-foreground">
          Update account details. Changes are saved when you submit.
        </div>
      </>
    ),
  },
  {
    value: 'Navigation',
    title: 'Navigation',
    icon: PanelLeft,
    description: (
      <>
        <p>
          Navigation should preserve orientation and reduce context switching.
        </p>

        <div className="mt-3 rounded-[5px] border border-border-subtle bg-muted/30 px-3 py-2 text-sm text-muted-foreground">
          Move between product areas without losing your current context.
        </div>
      </>
    ),
  },
]}
/>

## Common questions

<Accordions type="single">
  <Accordion title="Is Sheet different from Dialog?">
    Sheet is implemented with Dialog primitives, but the interaction model is different. Dialog is for focused modal decisions. Sheet is for side workflows that preserve page context.
  </Accordion>

  <Accordion title="Should filters use Sheet or Dropdown Menu?">
    Use Dropdown Menu for a few compact options. Use Sheet when filters are numerous, grouped, or need more explanation.
  </Accordion>

  <Accordion title="Can a Sheet contain a form?">
    Yes. Sheets work well for contextual editing and filter forms. For long or multi-step forms, use a dedicated page.
  </Accordion>

  <Accordion title="Should destructive actions use Sheet?">
    Usually no. Use Dialog for destructive confirmations because the decision should be focused and explicit.
  </Accordion>
</Accordions>

## Related

<DocsLinks
  variant="list"
  tone="platform"
  items={[
  {
    title: "Button",
    href: "/docs/ui/button",
    description:
      "Use Button as the trigger and footer action inside sheets.",
    icon: MousePointerClick,
  },
  {
    title: "Input",
    href: "/docs/ui/input",
    description:
      "Common inside sheets for edit forms and filters.",
    icon: FormInput,
  },
  {
    title: "Dialog",
    href: "/docs/ui/dialog",
    description:
      "Use Dialog for focused confirmations and short modal tasks.",
    icon: PanelTop,
  },
  {
    title: "Overlays pattern",
    href: "/docs/patterns/overlays",
    description:
      "Choose between Sheet, Dialog, and Dropdown Menu for product flows.",
    icon: Layers3,
  },
]}
/>