# Modal

> A modal dialog with title, description, body and footer.

- Category: [Overlays](https://tarve.dev/docs.md#overlays)
- Import: `import { Modal } from "@tarve/core";`
- Props type: `ModalProps`
- Source: [packages/core/src/components/modal.ts:26](https://github.com/omarcosr/tarve/blob/main/packages/core/src/components/modal.ts#L26)

## Usage

```tsx title="Modal.tsx"
import { Button, Input, Modal, Row } from "@tarve/core";

let open = true;
let name = "notes.md";

<>
  <Button variant="outline" onClick={() => (open = true)}>
    Rename file
  </Button>
  <Modal
    open={open}
    title="Rename file"
    description="Choose a new name for this file."
    onOpenChange={(next) => {
      open = next;
    }}
    footer={
      <Row gap={8} justify="end">
        <Button variant="outline" onClick={() => (open = false)}>Cancel</Button>
        <Button onClick={() => (open = false)}>Save</Button>
      </Row>
    }
  >
    <Input
      value={name}
      onChange={(value) => {
        name = value;
      }}
    />
  </Modal>
</>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` (required) | `boolean` | — |  |
| `closeOnEscape` | `boolean` | `true` |  |
| `closeOnOverlay` | `boolean` | `true` |  |
| `description` | `string` | — |  |
| `footer` | `Child` | — |  |
| `onOpenChange` | `(open: boolean) => void` | — |  |
| `scrollBody` | `boolean` | `true` | The panel never grows past the window (24 px margins): title and footer stay put and the body scrolls (a `Scroll`). Default `true`; `false` lays the body out unbounded, as before. |
| `showClose` | `boolean` | `true` |  |
| `title` | `string` | — |  |
| `width` | `number` | `480` |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

Previous: [Empty](https://tarve.dev/docs/components/Empty.md) · Next: [Dialog](https://tarve.dev/docs/components/Dialog.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Modal · Index for agents: https://tarve.dev/llms.txt
