---
title: Drawer
description: Present a swipeable surface from a viewport edge with snap points.
package: moraine
version: 0.11.0
repository: https://github.com/subframe7536/moraine
---

# Drawer

> Present a swipeable surface from a viewport edge with snap points.

## Anatomy

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

Content is portaled. Overlay and Content are siblings by default.

## Usage

Use Drawer for a mobile-style surface the user dismisses with a swipe along its edge, optionally
resting at snap points. Use [Sheet](https://moraine.subf.dev/components/sheet.md) for an edge panel without gestures. Use
[Dialog](https://moraine.subf.dev/components/dialog.md) for a centered labeled task, and [BaseDialog](https://moraine.subf.dev/components/base-dialog.md) to compose
backdrop and content yourself.

Drawer shares modal dismissal and focus behavior with Dialog. The default `side` is `bottom`. For a
persistent panel that coexists with the page, combine `modal={false}` with `overlay={false}`,
`preventScroll={false}`, and `closeOnOverlayClick={false}`. Escape and swipe dismissal still apply.

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

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

### Content composition

Use Content `title` and `description` for simple cases, or compose `Drawer.Header`, `Drawer.Title`,
`Drawer.Description`, `Drawer.Body`, and `Drawer.Footer` for a custom layout, following the same
contract as [Sheet](https://moraine.subf.dev/components/sheet.md#content-composition). An explicit `Drawer.Header` replaces the
generated header. `Drawer.Close` is an explicit close control. Root `closable` (default `true`) adds
the automatic corner close button, and `closeIcon` replaces its icon. The `drawer` message group
(`close`) names the button, and `translations` overrides it per drawer. A touch swipe that starts
on the button still dismisses.

Root `transition={false}` turns off the enter and exit animations. Content and overlay then unmount
as soon as the drawer closes instead of waiting for the animation to end.

For `top` and `bottom` sides, Content renders a decorative `handle` grab bar along the edge facing
the viewport. Set `handle={false}` to hide it.

### Sizing and scrolling

A `top` or `bottom` drawer sizes to its content and stops `0.5rem` (or the top safe-area inset, if
larger) short of the viewport height. `left` and `right` panels span `w-3/4`, up to `sm:max-w-sm`.
Override either with Content `class`, for example `class="h-[50dvh]"` for a fixed height or
`class="w-1/2 sm:max-w-2xl"` for a wider side panel. Body is the scrollable region: once Content's
height is bounded, it scrolls between the header and footer.

### Swipe to dismiss

The surface tracks a drag along its dismiss axis (down for `bottom`, up for `top`, outward for
`left` and `right`) and closes once dragged past half its size or on a fast flick. A drag against
the dismiss direction is damped and springs back. The `data-swiping` attribute on the content and
overlay marks the active gesture so transitions pause.

A mouse or pen drag does not start on interactive elements (`button`, `a`, form controls,
`[contenteditable]`, `[role="button"]`, `[role="slider"]`), inside `Drawer.Body`, which stays
available for text selection, or inside a region that scrolls along the drag axis. A touch drag can start on interactive
elements. Touch drags that begin inside a scrollable region defer to native scrolling until the
scroller reaches its edge in the drag direction.

Mark a subtree with `data-swipe-ignore` to block drags that start in it. On touch,
`data-swipe-ignore="x"` or `"y"` blocks only drags along that axis.

```tsx
<Drawer.Body>
  <div data-swipe-ignore>Drag-free region</div>
</Drawer.Body>
```

### Snap points

`snapPoints` limits where a `top` or `bottom` drawer rests. Each entry is the visible height from the
edge, in any order: numbers `<= 1` are a fraction of the viewport height, larger numbers are pixels,
and `'px'` or `'rem'` strings resolve directly. Snap points are ignored for `left` and `right`. Snap
heights are clamped to the content's rendered height and the viewport, so give Content an explicit
height (for example `class="h-[calc(100dvh-0.5rem)]"`) when using fractional or full snap points.

`snapPoint`, `defaultSnapPoint`, and `onSnapPointChange` control the resting point. It defaults to
the first snap point, and `null` means fully open. Releasing a swipe settles on the closest point
(projected by the swipe velocity), and dragging past the lowest point closes the drawer. With
`snapToSequentialPoints`, a flick advances at most one point and closes only from the lowest point.
After the drawer finishes closing, it returns to the default point and reports it through
`onSnapPointChange` if the active point differed.

```tsx
const [snapPoint, setSnapPoint] = createSignal<DrawerT.SnapPoint | null>('200px')

<Drawer snapPoints={['200px', 1]} snapPoint={snapPoint()} onSnapPointChange={setSnapPoint}>
```

### CSS variables

Content declares these variables. Override them with `styles.content`, or read them in your own styles.

| Variable                     | Default                                                     | Description                                                                |
| ---------------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------- |
| `--drawer-swipe-movement`    | `0px`                                                       | Current swipe offset along the surface axis.                               |
| `--drawer-snap-point-offset` | `0px`                                                       | Offset of the active snap point from fully open.                           |
| `--drawer-keyboard-inset`    | `0px`                                                       | Bottom inset reserved for the on-screen keyboard.                          |
| `--drawer-translate`         | per side                                                    | Translate applied to the surface; derives from the swipe and snap offsets. |
| `--drawer-max-height`        | `calc(100dvh - max(0.5rem, env(safe-area-inset-top, 0px)))` | Height cap for `top` and `bottom` sides.                                   |
| `--drawer-safe-area-bottom`  | `env(safe-area-inset-bottom, 0px)`                          | Resolved bottom safe-area inset.                                           |
| `--drawer-bottom-inset`      | max of safe area and `--drawer-keyboard-inset`              | Bottom padding of a `bottom` drawer.                                       |
| `--drawer-nested-num`        | `0`                                                         | Number of open drawers nested inside this drawer.                          |
| `--drawer-nested-progress`   | `0`                                                         | Swipe progress of the frontmost nested drawer in `[0, 1]`.                 |
| `--drawer-frontmost-height`  | `0px`                                                       | Measured popup height of the frontmost nested drawer.                      |
| `--drawer-nested-scale`      | derived from nested count and progress (`1` when none)      | Scale applied to recede ancestor drawers in a nested stack.                |
| `--drawer-nested-offset`     | derived from nested count and progress (`0px` when none)    | Offset applied to push ancestor drawers upward in a nested stack.          |

### Keyboard interaction

| Key                    | Description                                             |
| ---------------------- | ------------------------------------------------------- |
| <kbd>Escape</kbd>      | Dismisses the drawer unless `closeOnEscape` is `false`. |
| <kbd>Tab</kbd>         | Moves focus forward; modal drawers contain focus.       |
| <kbd>Shift + Tab</kbd> | Moves focus backward; modal drawers contain focus.      |

On Android, the system back gesture closes the drawer in browsers that support `CloseWatcher`. It
follows `closeOnEscape` and reports blocked requests through `onClosePrevented`.

## Examples

### Bottom sheet with a handle

The default `bottom` side shows the grab handle and dismisses on a downward swipe.

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

export function BottomUsage() {
  return (
    <Drawer>
      <Drawer.Trigger as={Button}>Open Bottom Drawer</Drawer.Trigger>
      <Drawer.Content title="Share" description="Swipe down or pick an action to dismiss.">
        <Drawer.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>
        </Drawer.Body>
      </Drawer.Content>
    </Drawer>
  )
}
```

### Rest at snap points

A controlled snap point switches between a compact peek and the full-height surface.

```tsx
import { Button, Drawer } from 'moraine'
import type { DrawerT } from 'moraine'
import { createSignal } from 'solid-js'

export function SnapPoints() {
  const [snapPoint, setSnapPoint] = createSignal<DrawerT.SnapPoint | null>('200px')

  return (
    <Drawer snapPoints={['200px', 1]} snapPoint={snapPoint()} onSnapPointChange={setSnapPoint}>
      <Drawer.Trigger as={Button}>Open Snap Drawer</Drawer.Trigger>
      <Drawer.Content
        class="h-[calc(100dvh-4rem)]"
        title="Snap points"
        description="Drag to rest at 200px or full height."
      >
        <Drawer.Body>
          <div class="text-xs text-muted-foreground py-4 space-y-3">
            <p>
              The drawer rests at a 200px peek or expands to the full surface. Drag the handle or
              the panel to move between them, or swipe down from the lowest point to close.
            </p>
            <div class="flex gap-2">
              <Button variant="outline" size="sm" onClick={() => setSnapPoint('200px')}>
                Peek
              </Button>
              <Button variant="outline" size="sm" onClick={() => setSnapPoint(1)}>
                Expand
              </Button>
            </div>
          </div>
        </Drawer.Body>
      </Drawer.Content>
    </Drawer>
  )
}
```

### Nest drawers

A child drawer opens above its parent: ancestors shrink and slide up behind it. Setting
`overlay={false}` on the nested drawers keeps a single overlay for the whole stack.
Escape, swipe, outside press, and the Android back gesture close only the topmost drawer.

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

export function Nested() {
  return (
    <Drawer>
      <Drawer.Trigger as={Button} variant="outline">
        Nested drawers
      </Drawer.Trigger>
      <Drawer.Content>
        <Drawer.Header class="text-center">
          <Drawer.Title>First step</Drawer.Title>
          <Drawer.Description>
            This is the first step. Tap the button below to continue to the next screen.
          </Drawer.Description>
        </Drawer.Header>
        <Drawer.Footer class="justify-center sm:justify-center">
          <Drawer.Close as={Button} variant="ghost">
            Cancel
          </Drawer.Close>
          <Drawer overlay={false}>
            <Drawer.Trigger as={Button} variant="outline">
              Continue
            </Drawer.Trigger>
            <Drawer.Content>
              <Drawer.Header class="text-center">
                <Drawer.Title>Second step</Drawer.Title>
                <Drawer.Description>
                  You&apos;ve reached the second step. Tap the button below to continue to the next
                  screen.
                </Drawer.Description>
              </Drawer.Header>
              <Drawer.Body>
                <div class="flex justify-center">
                  <div class="border border-border rounded-xl bg-muted shrink-0 size-48" />
                </div>
              </Drawer.Body>
              <Drawer.Footer class="justify-center sm:justify-center">
                <Drawer.Close as={Button} variant="ghost">
                  Back
                </Drawer.Close>
                <Drawer overlay={false}>
                  <Drawer.Trigger as={Button} variant="outline">
                    Continue
                  </Drawer.Trigger>
                  <Drawer.Content>
                    <Drawer.Header class="text-center">
                      <Drawer.Title>Third step</Drawer.Title>
                      <Drawer.Description>
                        You&apos;ve reached the final step. You can close this drawer or go back.
                      </Drawer.Description>
                    </Drawer.Header>
                    <Drawer.Body>
                      <div class="flex justify-center">
                        <div class="border border-border rounded-full bg-muted shrink-0 size-32" />
                      </div>
                    </Drawer.Body>
                  </Drawer.Content>
                </Drawer>
              </Drawer.Footer>
            </Drawer.Content>
          </Drawer>
        </Drawer.Footer>
      </Drawer.Content>
    </Drawer>
  )
}
```

### Open from different edges

Top and bottom support handles and snap points; left and right are swipe-only panels.

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

export function Sides() {
  return (
    <div class="flex flex-wrap gap-3 items-center">
      <Drawer side="bottom">
        <Drawer.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:chevron-down">
          Bottom
        </Drawer.Trigger>
        <Drawer.Content title="Bottom drawer" description="Swipe down to dismiss.">
          <Drawer.Body>
            <div class="text-xs text-muted-foreground py-2">
              Bottom drawers show the handle first and follow a downward drag.
            </div>
          </Drawer.Body>
        </Drawer.Content>
      </Drawer>

      <Drawer side="top">
        <Drawer.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:chevron-up">
          Top
        </Drawer.Trigger>
        <Drawer.Content title="Top drawer" description="Swipe up to dismiss.">
          <Drawer.Body>
            <div class="text-xs text-muted-foreground py-2">
              Top drawers pin to the top edge and move the handle to the end.
            </div>
          </Drawer.Body>
        </Drawer.Content>
      </Drawer>

      <Drawer side="left">
        <Drawer.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:panel-left">
          Left
        </Drawer.Trigger>
        <Drawer.Content title="Left drawer" description="Swipe left to dismiss.">
          <Drawer.Body>
            <div class="text-xs text-muted-foreground py-2">
              Side drawers skip the handle and snap points.
            </div>
          </Drawer.Body>
        </Drawer.Content>
      </Drawer>

      <Drawer side="right">
        <Drawer.Trigger as={Button} variant="outline" size="sm" leading="i-lucide:panel-right">
          Right
        </Drawer.Trigger>
        <Drawer.Content title="Right drawer" description="Swipe right to dismiss.">
          <Drawer.Body>
            <div class="text-xs text-muted-foreground py-2">
              Right drawers track a horizontal drag toward the edge.
            </div>
          </Drawer.Body>
        </Drawer.Content>
      </Drawer>
    </div>
  )
}
```

### Keep the page interactive

`modal={false}`, `overlay={false}`, and `preventScroll={false}` leave the page's pointer, focus,
and scroll access intact; `closeOnOverlayClick={false}` keeps outside presses from dismissing the
panel — both buttons update the same count.

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

export function NonModal() {
  const [count, setCount] = createSignal(0)

  return (
    <div class="max-w-sm w-full space-y-3">
      <div class="text-xs text-muted-foreground leading-relaxed">
        The panel floats without an overlay or focus trap — the page button below stays live while
        it is open. Count: {count()}
      </div>
      <div class="flex flex-wrap gap-2">
        <Button variant="outline" size="sm" onClick={() => setCount((value) => value + 1)}>
          Page action
        </Button>
        <Drawer
          modal={false}
          overlay={false}
          preventScroll={false}
          closeOnOverlayClick={false}
          closable
        >
          <Drawer.Trigger as={Button} size="sm">
            Open Panel
          </Drawer.Trigger>
          <Drawer.Content
            title="Quick actions"
            description="Escape, a downward swipe, or the close button dismisses."
          >
            <Drawer.Body>
              <div class="py-2 flex gap-2">
                <Button variant="outline" size="sm" onClick={() => setCount((value) => value + 1)}>
                  Increment
                </Button>
                <Button variant="outline" size="sm" onClick={() => setCount(0)}>
                  Reset
                </Button>
              </div>
            </Drawer.Body>
          </Drawer.Content>
        </Drawer>
      </div>
    </div>
  )
}
```

### Swap Dialog and Drawer responsively

`createMediaQuery` renders the same task in a [Dialog](https://moraine.subf.dev/components/dialog.md) on wide screens and a
Drawer on narrow ones. Resize the window to see the trigger swap.

```tsx
import { Button, Dialog, Drawer, Field, Input } from 'moraine'
import { createMediaQuery } from 'moraine/utils'
import { Show } from 'solid-js'

function ProfileFields() {
  return (
    <div class="gap-4 grid">
      <Field label="Name">
        <Input defaultValue="Sarah Connor" />
      </Field>
      <Field label="Username">
        <Input defaultValue="@sconnor" />
      </Field>
    </div>
  )
}

export function Responsive() {
  const isDesktop = createMediaQuery('(min-width: 768px)')

  return (
    <Show
      when={isDesktop()}
      fallback={
        <Drawer>
          <Drawer.Trigger as={Button} variant="outline">
            Edit Profile
          </Drawer.Trigger>
          <Drawer.Content
            title="Edit profile"
            description="Make changes to your profile here. Click save when you're done."
          >
            <Drawer.Body>
              <ProfileFields />
            </Drawer.Body>
            <Drawer.Footer>
              <Drawer.Close as={Button}>Save changes</Drawer.Close>
            </Drawer.Footer>
          </Drawer.Content>
        </Drawer>
      }
    >
      <Dialog>
        <Dialog.Trigger as={Button} variant="outline">
          Edit Profile
        </Dialog.Trigger>
        <Dialog.Content
          title="Edit profile"
          description="Make changes to your profile here. Click save when you're done."
        >
          <Dialog.Body>
            <ProfileFields />
          </Dialog.Body>
          <Dialog.Footer>
            <Dialog.Close as={Button}>Save changes</Dialog.Close>
          </Dialog.Footer>
        </Dialog.Content>
      </Dialog>
    </Show>
  )
}
```

## API Reference

### Attributes

| Attributes | Slot | Description |
| --- | --- | --- |
| `data-closed` | `drawer-trigger`, `drawer-content`, `drawer-overlay` | Present when disclosure or transition content is closed. |
| `data-disabled` | `drawer-trigger` | Present when the component, slot, or item is disabled. |
| `data-expanded` | `drawer-trigger`, `drawer-content`, `drawer-overlay` | Present when the panel, accordion, or menu is expanded. |
| `data-swiping` | `drawer-content`, `drawer-overlay` | Present while a swipe gesture is dragging the element. |
| `data-transition` | `drawer-content`, `drawer-overlay` | Present while a target participates in a visibility transition. |
| `data-handle` | `drawer-content` | Present when the drawer grab handle is rendered. |
| `data-nested-open` | `drawer-content` | Present on an ancestor drawer while a nested drawer is mounted. |
| `data-nested-swiping` | `drawer-content` | Present on an ancestor drawer while a nested drawer is being dragged. |
| `data-footer` | `drawer-body` | Present when the component renders footer content. |
| `data-header` | `drawer-body` | Present when the component renders header content. |
| `data-body` | `drawer-header`, `drawer-footer` | Present when the component renders body content. |

### Props

#### Drawer

| 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. |
| defaultSnapPoint | SnapPoint \| null \| undefined | snapPoints[0] ?? null | Snap point the drawer opens at when `snapPoint` is not set. The drawer returns to it after<br>each close. |
| 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`. |
| handle | boolean \| undefined | true | Whether to render the decorative grab handle. It is only rendered when `side` is `top` or<br>`bottom`. |
| 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`. |
| 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. |
| onSnapPointChange | ((snapPoint: SnapPoint \| null) => void) \| undefined | — | Called with the new active snap point when a swipe settles on a different one, and with the<br>default point after the drawer has finished closing, if the active point differed. `null`<br>means fully open. |
| 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 | 'bottom' | Viewport edge used by the component Recipe. |
| snapPoint | SnapPoint \| null \| undefined | — | Controlled active snap point, normally one of the `snapPoints` entries. `null` selects the<br>fully open position and `undefined` leaves the state uncontrolled (see `defaultSnapPoint`). Update it<br>from `onSnapPointChange`. |
| snapPoints | SnapPoint[] \| undefined | — | Visible heights the drawer can rest at, measured from the edge it opens from, in any order.<br>Each is a number (`<= 1` is a fraction of the viewport height, `> 1` is pixels) or a `px` or<br>`rem` string; heights are clamped to the drawer and the viewport. Releasing a swipe settles<br>on the closest point (projected by the swipe velocity), and dragging past the lowest point<br>dismisses the drawer. Only honored when `side` is `top` or `bottom`. |
| snapToSequentialPoints | boolean \| undefined | false | Whether a fast flick settles on the next adjacent snap point (or dismisses past the lowest<br>one) instead of projecting the swipe velocity onto the closest point. |
| 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 drawer, 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>
```

**`onSnapPointChange` example**

```tsx
import { Button, Drawer } from 'moraine'
import type { DrawerT } from 'moraine'
import { createSignal } from 'solid-js'

const [snapPoint, setSnapPoint] = createSignal<DrawerT.SnapPoint | null>(0.4)

<Drawer snapPoints={[0.4, 1]} snapPoint={snapPoint()} onSnapPointChange={setSnapPoint}>
  <Drawer.Trigger as={Button}>Open</Drawer.Trigger>
  <Drawer.Content title="Details">Drawer content</Drawer.Content>
</Drawer>
```

**`snapPoints` example**

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

<Drawer snapPoints={[0.4, '24rem', 1]}>
  <Drawer.Trigger as={Button}>Open</Drawer.Trigger>
  <Drawer.Content title="Details">Drawer content</Drawer.Content>
</Drawer>
```

**`translations` example**

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

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

#### Drawer.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. |

#### Drawer.Content

Props for Drawer.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 `Drawer.Header`. |
| title | JSX.Element \| undefined | — | Title rendered in a generated header, and used as the accessible name of the drawer<br>(`aria-labelledby`, unless `aria-label` is set). Ignored when the children include an<br>explicit `Drawer.Header`. |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| Component<ContentRenderProps> \| undefined | — | Composable drawer 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. |

#### Drawer.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. |

#### Drawer.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. |

#### Drawer.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. |

#### Drawer.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. |

#### Drawer.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. |

#### Drawer.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. |
