Dialog

Dialogs display content that requires user interaction in a focused overlay.


Installation

npm install @libretexts/davis-react

Basic Usage

import { Dialog, Button } from '@libretexts/davis-react';
import { useState } from 'react';

export default function Example() {
  const [open, setOpen] = useState(false);

  return (
    <>
      <Button onClick={() => setOpen(true)}>Open Dialog</Button>
      <Dialog open={open} onClose={() => setOpen(false)}>
        <Dialog.Header>
          <Dialog.Title>Dialog Title</Dialog.Title>
        </Dialog.Header>
        <Dialog.Body>
          <p>Dialog content goes here.</p>
        </Dialog.Body>
        <Dialog.Footer>
          <Button onClick={() => setOpen(false)}>Close</Button>
        </Dialog.Footer>
      </Dialog>
    </>
  );
}


When to use

  • Dialog — Use for interactions that require the user's full attention before returning to the page: confirmation prompts, data entry forms that replace existing state, or critical warnings. Dialog blocks the page with a backdrop.
  • Drawer — Use for contextual detail panels, filter sidebars, and settings that the user may want to reference while keeping the underlying page partially visible. Drawer is less disruptive than Dialog.

Documentation in Progress

Full documentation for this component is being written. Check back soon for complete API reference, examples, and accessibility guidelines.