# Modal

> Centered modal dialog built on Base UI Dialog.

Registry name: `modal`. HTML docs: https://ui.anuragroy.dev/component/modal.

## Install

```bash
npx shadcn@latest add https://ui.anuragroy.dev/r/modal.json
```

If the website is down: `npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/modal.json`.

Registry JSON: https://ui.anuragroy.dev/r/modal.json (GitHub: https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/modal.json).

## Import

Import paths follow the consumer `components.json` aliases. After a default install:

```tsx
import {
  Modal,
  ModalContent,
  ModalDescription,
  ModalFooter,
  ModalHeader,
  ModalTitle,
  ModalTrigger
} from "@/components/ui/modal"
```

## Usage

```tsx
import { Button } from "@/components/ui/button"
import {
  Modal,
  ModalContent,
  ModalDescription,
  ModalFooter,
  ModalHeader,
  ModalTitle,
  ModalTrigger,
} from "@/components/ui/modal"

export function Example() {
  return (
    <Modal>
      <ModalTrigger render={<Button />}>Open modal</ModalTrigger>
      <ModalContent>
        <ModalHeader>
          <ModalTitle>Modal title</ModalTitle>
          <ModalDescription>Built on Base UI Dialog.</ModalDescription>
        </ModalHeader>
        <ModalFooter>
          <Button>Continue</Button>
        </ModalFooter>
      </ModalContent>
    </Modal>
  )
}
```

## API

### Modal

Dialog root. Controlled via `open` / `onOpenChange`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | boolean | — |  |
| `onOpenChange` | (open: boolean) => void | — |  |

### ModalContent

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `showCloseButton` | boolean | true |  |

## Notes

- `ModalTitle` is required for accessibility. Use `className="sr-only"` if you hide it visually.
- Compose custom triggers with `render`, not `asChild`.

## See also

- [HTML page](https://ui.anuragroy.dev/component/modal): Preview and the same docs in the site chrome.
- [Registry item](https://ui.anuragroy.dev/r/modal.json): Source files and dependencies.
- [Catalog](https://ui.anuragroy.dev/component): All components.
- [llms.txt](https://ui.anuragroy.dev/llms.txt): Agent index for this library.
