Skip to main content

Modal

A modal displays content in a layer that overlays the page content.

On this page
Props
<Dialog>
  <Button>Open Modal</Button>
  <Modal>
    <DialogContent>
      <DialogHeader>
        <DialogTitle>Modal Title</DialogTitle>
        <DialogDescription>This is a modal description.</DialogDescription>
      </DialogHeader>
      <DialogBody>
        <p>Modal content goes here.</p>
      </DialogBody>
      <DialogFooter>
        <Button slot="close">Cancel</Button>
        <Button slot="close" variant="primary">
          Confirm
        </Button>
      </DialogFooter>
    </DialogContent>
  </Modal>
</Dialog>

Installation

npx shadcn@latest add @dotui/modal

Usage

Use modals to display content in a layer that overlays the page content.

import { Button } from '@/components/ui/button'
import { Dialog, DialogContent } from '@/components/ui/dialog'
import { Modal } from '@/components/ui/modal'
<Dialog>
  <Button>Open Modal</Button>
  <Modal>
    <DialogContent>Modal content</DialogContent>
  </Modal>
</Dialog>

Examples

API Reference

A modal is an overlay element which blocks interaction with elements outside it.

PropType
boolean
boolean
Element
boolean
boolean
ReactNode | function
function

ModalOverlay

A ModalOverlay is a wrapper for a Modal which allows customizing the backdrop element.

PropType
Element
ReactNode | function
boolean
boolean
boolean
boolean
function

ModalBackdrop

The backdrop displayed behind the modal, which dims the underlying page content.

Supports all div attributes.

PropType

ModalViewport

The viewport container that centers the modal within the visible area of the screen.

Supports all div attributes.

PropType

ModalContent

The modal panel that contains the dialog content.

PropType
Element
ReactNode | function
boolean
boolean
boolean
boolean
function

Last updated on 6/16/2026