---
title: Sheet
description: Present a focused drawer from a viewport edge.
package: moraine
version: 0.11.0
repository: https://github.com/subframe7536/moraine
---

# Sheet

> Present a focused drawer from a viewport edge.

## Anatomy

```text
Sheet [component; no DOM]
├── Sheet.Trigger [part; slot=trigger]
├── Sheet.Close [part]
└── overlay [slot]
    └── Sheet.Content [part; slot=content]
        ├── Sheet.Header [part; slot=header]
        │   ├── Sheet.Title [part; slot=title]
        │   └── Sheet.Description [part; slot=description]
        ├── contentClose [slot]
        ├── Sheet.Body [part; slot=body]
        └── Sheet.Footer [part; slot=footer]
```

Content is portaled and renders inside the overlay element. With `overlay={false}`, that element is an unstyled wrapper without the `overlay` slot.

## Usage

Use Sheet for a focused drawer from a viewport edge, such as mobile navigation or an inspector. Use
[Drawer](https://moraine.subf.dev/components/drawer.md) when the surface needs swipe-to-dismiss gestures or snap points. Use
[Dialog](https://moraine.subf.dev/components/dialog.md) for a centered labeled task. Use [BaseDialog](https://moraine.subf.dev/components/base-dialog.md) to compose
backdrop and content yourself. Use [Popover](https://moraine.subf.dev/components/popover.md) for anchored content that should
not take over the page. Use [DropdownMenu](https://moraine.subf.dev/components/dropdown-menu.md) for a compact action list.

Sheet shares modal dismissal and focus behavior with Dialog.

```tsx
import { Button, Sheet } from 'moraine'

export function Example() {
  return (
    <Sheet>
      <Sheet.Trigger as={Button}>Open</Sheet.Trigger>
      <Sheet.Content title="Details">
        <Sheet.Body>Sheet content</Sheet.Body>
        <Sheet.Footer>
          <Sheet.Close as={Button}>Done</Sheet.Close>
        </Sheet.Footer>
      </Sheet.Content>
    </Sheet>
  )
}
```

### Content composition

Use Content `title` and `description` for simple cases:

```tsx
<Sheet>
  <Sheet.Content title="Settings" description="Update your account.">
    <Sheet.Body>...</Sheet.Body>
    <Sheet.Footer>...</Sheet.Footer>
  </Sheet.Content>
</Sheet>
```

For a custom header layout, compose the anatomy parts:

```tsx
<Sheet.Content>
  <Sheet.Header>
    <Sheet.Title>Settings</Sheet.Title>
    <Sheet.Description>Update your account.</Sheet.Description>
  </Sheet.Header>
  <Sheet.Body>...</Sheet.Body>
  <Sheet.Footer>...</Sheet.Footer>
</Sheet.Content>
```

An explicit `Sheet.Header` replaces the header generated by Content's `title` and `description`.
`Sheet.Title` and `Sheet.Description` connect their IDs to the surface's accessible name and
description. Without a visible title, set `aria-label` or `aria-labelledby` on Content.

`Sheet.Close` is an explicit close control you can place inside the root; it is separate from
Content's automatic corner close button. Set root `closable={false}` to hide the corner button, or
`closeIcon` to replace its icon. Its accessible label comes from the `close` message; override it
with root `translations`. See [Localization](https://moraine.subf.dev/docs/localization.md). Root `transition={false}` turns
off the enter and exit animations, so content and overlay unmount as soon as the sheet closes.

### Focus and outside interaction

`modal` defaults to `true`: focus stays inside the surface, outside content is hidden from assistive
technology, and native outside pointer actions are prevented. Closing restores focus to the trigger.
Use `initialFocus` to choose the element that receives focus on open, or `false` to skip the move,
and `finalFocus` to choose where focus returns. Both apply only while `modal` is `true`.

Setting `modal={false}` allows focus to leave the surface, but does not disable Escape or outside
dismissal. `closeOnOverlayClick` and `closeOnEscape` control those close requests. Both default to
`true`. Scroll locking is independent: `preventScroll` defaults to `true`. For interaction with the
background page, also set `preventScroll={false}` and `overlay={false}`.

### Styling and portal placement

Apply `class` and object `style` directly to each rendered part. Root `classes` and `styles` set
slot defaults for every part: `trigger`, `overlay`, `content`, `header`, `title`, `description`,
`contentClose`, `body`, and `footer`. See
[Customization](https://moraine.subf.dev/docs/customization.md#the-4-layer-override-hierarchy) for precedence.

Set root `mount` to place Content in a chosen container. This also works for controlled
surfaces without a Trigger.

### Structured drawer

Choose the viewport edge with root `side` (`top`, `right`, `bottom`, or `left`; default `right`), and set `inset` when the sheet needs space around it.
Compose body and footer regions to keep the task content separate from its actions.

```tsx
<Sheet side="right">
  <Sheet.Trigger as={Button}>Open settings</Sheet.Trigger>
  <Sheet.Content title="Settings" description="Fields in the body, actions in the footer.">
    <Sheet.Body>...</Sheet.Body>
    <Sheet.Footer>
      <Sheet.Close as={Button}>Done</Sheet.Close>
    </Sheet.Footer>
  </Sheet.Content>
</Sheet>
```

### State and dismissal

Use controlled open state when a layout owns visibility. Disable normal dismissal only when the
sheet has a clear explicit close action; `onClosePrevented` receives blocked outside or Escape
attempts.

```tsx
<Sheet open={open()} onOpenChange={setOpen}>
  <Sheet.Content title="Controlled sheet">
    <Sheet.Footer>
      <Button onClick={() => setOpen(false)}>Done</Button>
    </Sheet.Footer>
  </Sheet.Content>
</Sheet>
<Sheet closeOnOverlayClick={false} closeOnEscape={false} onClosePrevented={onBlocked}>
  <Sheet.Content title="Persistent sheet">
    <Sheet.Footer>
      <Button onClick={() => setOpen(false)}>Close</Button>
    </Sheet.Footer>
  </Sheet.Content>
</Sheet>
```

### Keyboard interaction

| Key                    | Description                                             |
| ---------------------- | ------------------------------------------------------- |
| <kbd>Escape</kbd>      | Requests dismissal when `closeOnEscape` is not `false`. |
| <kbd>Tab</kbd>         | Moves focus forward; modal sheets contain focus.        |
| <kbd>Shift + Tab</kbd> | Moves focus backward; modal sheets contain focus.       |

## Examples

### Edit settings

Place fields in the body and Cancel/Done in the footer. The default side is `right`.

```tsx
import { Button, Sheet } from 'moraine'

export function SettingsUsage() {
  return (
    <Sheet>
      <Sheet.Trigger as={Button}>Open Settings</Sheet.Trigger>
      <Sheet.Content title="Settings" description="Fields in the body, actions in the footer.">
        <Sheet.Body>
          <div class="text-xs text-muted-foreground py-4">
            Place settings fields in this region and actions in the footer.
          </div>
        </Sheet.Body>
        <Sheet.Footer>
          <div class="flex gap-2 w-full justify-end">
            <Sheet.Close as={Button} variant="ghost">
              Cancel
            </Sheet.Close>
            <Sheet.Close as={Button}>Done</Sheet.Close>
          </div>
        </Sheet.Footer>
      </Sheet.Content>
    </Sheet>
  )
}
```

### Open a sheet from layout state

A page button owns `open`. Closing from the footer reports back through `onOpenChange`.

```tsx
import { Button, Sheet } from 'moraine'
import { createSignal } from 'solid-js'

export function StateUsage() {
  const [open, setOpen] = createSignal(false)

  return (
    <div>
      <Button onClick={() => setOpen(true)}>Open Managed Sheet</Button>
      <Sheet open={open()} onOpenChange={setOpen}>
        <Sheet.Content
          title="Controlled Sheet"
          description="Controlled open state enables external workflow triggers."
        >
          <Sheet.Body>
            <p class="text-xs text-muted-foreground py-2">
              Reactive state is managed by parent container.
            </p>
          </Sheet.Body>
          <Sheet.Footer>
            <div class="flex w-full justify-end">
              <Button size="xs" onClick={() => setOpen(false)}>
                Done
              </Button>
            </div>
          </Sheet.Footer>
        </Sheet.Content>
      </Sheet>
    </div>
  )
}
```

### Keep a sheet open until an explicit close

`closeOnOverlayClick={false}` and `closeOnEscape={false}` block overlay click and Escape, and
`onClosePrevented` reports each blocked attempt. The footer action is the only way to close.

```tsx
import { Button, Sheet } from 'moraine'
import { createSignal } from 'solid-js'

export function DismissControl() {
  const [open, setOpen] = createSignal(false)
  const [preventedCloseCount, setPreventedCloseCount] = createSignal(0)

  return (
    <div class="flex flex-wrap gap-3 items-center">
      <Sheet
        open={open()}
        onOpenChange={setOpen}
        closeOnOverlayClick={false}
        closeOnEscape={false}
        onClosePrevented={() => setPreventedCloseCount((value) => value + 1)}
      >
        <Sheet.Trigger as={Button} variant="outline">
          Open persistent sheet
        </Sheet.Trigger>
        <Sheet.Content
          title="Persistent sheet"
          description="Outside click and Escape key dismissal are blocked."
        >
          <Sheet.Body>
            <div class="py-2 space-y-3">
              <p class="text-sm text-muted-foreground">
                This sheet cannot be dismissed by clicking the overlay or pressing Escape.
              </p>
              <p class="text-sm text-foreground">
                Prevented close attempts: <span class="font-medium">{preventedCloseCount()}</span>
              </p>
            </div>
          </Sheet.Body>
          <Sheet.Footer>
            <div class="flex w-full justify-end">
              <Button size="sm" onClick={() => setOpen(false)}>
                Close sheet
              </Button>
            </div>
          </Sheet.Footer>
        </Sheet.Content>
      </Sheet>
    </div>
  )
}
```

### Open navigation, a cart, or share from different edges

Left holds navigation, right a cart with checkout, and bottom share actions.

```tsx
import { Button, Sheet } from 'moraine'

export function Sides() {
  return (
    <div class="flex flex-wrap gap-3 items-center">
      <Sheet side="left">
        <Sheet.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:panel-left">
          Left (Navigation)
        </Sheet.Trigger>
        <Sheet.Content title="Application Navigation" description="Jump to any workspace section.">
          <Sheet.Body>
            <div class="py-2 space-y-2">
              <Button
                variant="ghost"
                class="w-full justify-start"
                leading="i-lucide:layout-dashboard"
              >
                Dashboard
              </Button>
              <Button
                variant="ghost"
                class="w-full justify-start"
                leading="i-lucide:git-pull-request"
              >
                Pull Requests
              </Button>
              <Button variant="ghost" class="w-full justify-start" leading="i-lucide:server">
                Deployments
              </Button>
              <Button variant="ghost" class="w-full justify-start" leading="i-lucide:settings">
                Settings
              </Button>
            </div>
          </Sheet.Body>
        </Sheet.Content>
      </Sheet>

      <Sheet side="right">
        <Sheet.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:shopping-cart">
          Right (Cart Drawer)
        </Sheet.Trigger>
        <Sheet.Content
          title="Shopping Cart (2 items)"
          description="Review your selected items before checkout."
        >
          <Sheet.Body>
            <div class="text-xs py-2 space-y-3">
              <div class="p-2 rounded-lg bg-muted/40 flex items-center justify-between">
                <div>
                  <p class="font-medium">Canvas backpack</p>
                  <p class="text-muted-foreground">Qty: 1</p>
                </div>
                <span class="font-mono font-semibold">$199.00</span>
              </div>
              <div class="p-2 rounded-lg bg-muted/40 flex items-center justify-between">
                <div>
                  <p class="font-medium">Travel organizer</p>
                  <p class="text-muted-foreground">Qty: 1</p>
                </div>
                <span class="font-mono font-semibold">$49.00</span>
              </div>
            </div>
          </Sheet.Body>
          <Sheet.Footer>
            <Button class="w-full">Proceed to Checkout ($248.00)</Button>
          </Sheet.Footer>
        </Sheet.Content>
      </Sheet>

      <Sheet side="bottom">
        <Sheet.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:share-2">
          Bottom (Share)
        </Sheet.Trigger>
        <Sheet.Content
          title="Share Resource"
          description="Share this repository or report with teammates."
        >
          <Sheet.Body>
            <div class="py-2 flex flex-wrap gap-2">
              <Button variant="outline" size="sm" leading="i-lucide:copy">
                Copy Link
              </Button>
              <Button variant="outline" size="sm" leading="i-lucide:mail">
                Email Team
              </Button>
              <Button variant="outline" size="sm" leading="i-lucide:qr-code">
                Show QR
              </Button>
            </div>
          </Sheet.Body>
        </Sheet.Content>
      </Sheet>
    </div>
  )
}
```

## API Reference

### Attributes

| Attributes | Slot | Description |
| --- | --- | --- |
| `data-closed` | `sheet-trigger`, `sheet-content`, `sheet-overlay` | Present when disclosure or transition content is closed. |
| `data-disabled` | `sheet-trigger` | Present when the component, slot, or item is disabled. |
| `data-expanded` | `sheet-trigger`, `sheet-content`, `sheet-overlay` | Present when the panel, accordion, or menu is expanded. |
| `data-overlay-scroll` | `sheet-overlay` | Present when scrolling is owned by the overlay. |
| `data-transition` | `sheet-content`, `sheet-overlay` | Present while a target participates in a visibility transition. |
| `data-header` | `sheet-body` | Present when the component renders header content. |

### Props

#### Sheet

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| closable | boolean \| undefined | true | Whether to show the corner close button inside the content. Its accessible label comes from<br>the `close` translation. |
| closeIcon | IconT.Name \| undefined | 'icon-close' | Name of the icon shown in the corner close button. |
| closeOnEscape | boolean \| undefined | true | Whether Escape dismisses the shell.<br>`false` blocks Escape and reports it through `onClosePrevented`. |
| closeOnOverlayClick | boolean \| undefined | true | Whether a pointer press outside the content, such as on the backdrop, dismisses the shell.<br>`false` blocks the press and reports it through `onClosePrevented`. |
| defaultOpen | boolean \| undefined | false | Initial open state when uncontrolled. Ignored while `open` is set. |
| finalFocus | HTMLElement \| (() => HTMLElement \| undefined) \| false \| undefined | — | Element (or accessor resolving to one) that receives focus after the shell closes, or<br>`false` to skip the close-time focus restore. Defaults to the trigger, then the element<br>focused when the shell opened. An accessor that returns `undefined` restores no focus. Only<br>applies while `modal` is `true`. |
| id | string \| undefined | — | Unique identifier used to derive the content id, which becomes `<id>-content`. Generated<br>when omitted. |
| initialFocus | HTMLElement \| (() => HTMLElement \| undefined) \| false \| undefined | — | Element (or accessor resolving to one) that receives focus when the shell opens, or `false`<br>to skip the open-time focus move. Defaults to the first focusable element inside the<br>content, preferring an `[autofocus]` or `[data-autofocus]` descendant, and to the content<br>itself when opened by touch. An accessor that returns `undefined` falls back to the default.<br>Only applies while `modal` is `true`. |
| inset | boolean \| undefined | false | Whether the surface is inset from viewport edges. |
| modal | boolean \| undefined | true | Whether the surface contains focus, restores focus on close, hides outside content from<br>assistive technology, and prevents the native default action of outside pointer events.<br>Outside pointer dismissal is controlled by `closeOnOverlayClick`.<br>Escape dismissal is controlled by `closeOnEscape`. When `false`, focus is neither trapped,<br>moved on open nor restored on close, so `initialFocus` and `finalFocus` have no effect. |
| mount | Node \| undefined | — | DOM node that `BaseDialog.Portal`, and the content of `Dialog`, `Sheet` and `Drawer`, render into,<br>for example a container element or a shadow root. A `mount` on `BaseDialog.Portal` takes<br>precedence. Defaults to the `body` of the trigger's document. |
| onClosePrevented | (() => void) \| undefined | — | Called with no arguments when Escape (`closeOnEscape` is `false`) or an outside press<br>(`closeOnOverlayClick` is `false`) tried to close the shell and was blocked. |
| onExitComplete | (() => void) \| undefined | — | Called once after a close has finished: the exit motion is over and the content is<br>unmounted. With `transition` set to `false` there is no motion to wait for. It is not called<br>when the content is removed while still open. |
| onOpenChange | ((open: boolean) => void) \| undefined | — | Called with the next open state when the trigger, a close part, Escape or an outside press<br>requests a change. It is not called when `open` is changed from outside, and it does not<br>apply the change itself when `open` is controlled: update `open` in the handler. |
| open | boolean \| undefined | — | Controlled open state. Pair it with `onOpenChange`; leave it `undefined` to let the component<br>manage its own state (see `defaultOpen`). |
| overlay | boolean \| undefined | true | Whether to render the styled backdrop behind the content. When `false` the content is shown<br>without a backdrop; outside presses still follow `closeOnOverlayClick`. |
| preventScroll | boolean \| undefined | true | Whether body scroll should be locked while the shell is present. |
| side | 'top' \| 'right' \| 'bottom' \| 'left' \| undefined | 'right' | Viewport edge used by the component Recipe. |
| transition | boolean \| undefined | true | Whether enter and exit transition animations play. When `false`, the content and overlay<br>mount and unmount without waiting for an animation to end. The value is read when content<br>registers, so changes take effect the next time content mounts. |
| translations | Translations \| undefined | — | Overrides for the built-in strings of this sheet, merged over the `MoraineProvider` locale.<br>Only `close` is used here: the accessible label of the corner close button. |
| children | JSX.Element \| undefined | — | Composed trigger and content primitives. |
| classes | Classes \| undefined | — | Family slot class defaults for this instance. |
| styles | Styles \| undefined | — | Family slot style defaults for this instance. |

**`finalFocus` example**

```tsx
import { Button, Dialog } from 'moraine'

<Dialog finalFocus={() => document.getElementById('search') ?? undefined}>
  <Dialog.Trigger as={Button}>Open</Dialog.Trigger>
  <Dialog.Content title="Settings">Preferences</Dialog.Content>
</Dialog>
```

**`initialFocus` example**

```tsx
import { Button, Dialog } from 'moraine'
import { createSignal } from 'solid-js'

const [input, setInput] = createSignal<HTMLInputElement>()

<Dialog initialFocus={() => input()}>
  <Dialog.Trigger as={Button}>Rename</Dialog.Trigger>
  <Dialog.Content title="Rename">
    <input ref={setInput} />
  </Dialog.Content>
</Dialog>
```

**`mount` example**

```tsx
import { Button, Dialog } from 'moraine'

const container = document.getElementById('overlay-root') ?? document.body

<Dialog mount={container}>
  <Dialog.Trigger as={Button}>Open</Dialog.Trigger>
  <Dialog.Content title="Settings">Preferences</Dialog.Content>
</Dialog>
```

**`onOpenChange` example**

```tsx
import { Button, Dialog } from 'moraine'
import { createSignal } from 'solid-js'

const [open, setOpen] = createSignal(false)

<Dialog open={open()} onOpenChange={setOpen}>
  <Dialog.Trigger as={Button}>Open</Dialog.Trigger>
  <Dialog.Content title="Settings">Preferences</Dialog.Content>
</Dialog>
```

**`translations` example**

```tsx
import { Button, Sheet } from 'moraine'

<Sheet translations={{ close: 'Fermer' }}>
  <Sheet.Trigger as={Button}>Open</Sheet.Trigger>
  <Sheet.Content title="Réglages">Préférences</Sheet.Content>
</Sheet>
```

#### Sheet.Trigger

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| disabled | boolean \| undefined | — | Whether this trigger is disabled. |
| as | T \| undefined | 'button' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Trigger label and visual content. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Content

Props for Sheet.Content.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| description | JSX.Element \| undefined | — | Description rendered below the title in the generated header, and referenced by<br>`aria-describedby`. Ignored when the children include an explicit `Sheet.Header`. |
| title | JSX.Element \| undefined | — | Title rendered in a generated header, and used as the accessible name of the sheet<br>(`aria-labelledby`, unless `aria-label` is set). Ignored when the children include an<br>explicit `Sheet.Header`. |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| Component<ContentRenderProps> \| undefined | — | Composable sheet parts or render function receiving close action.<br>A render function must declare its parameter, even when unused. A zero-argument<br>function is called as an accessor and is not mounted as a component. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Header

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Title

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| id | string \| undefined | — | Unique identifier applied to the rendered element. |
| as | T \| undefined | 'h2' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Description

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| id | string \| undefined | — | Unique identifier applied to the rendered element. |
| as | T \| undefined | 'p' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Body

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Footer

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Sheet.Close

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| disabled | boolean \| undefined | — | Whether this trigger is disabled. |
| as | T \| undefined | 'button' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Trigger label and visual content. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |
