# Dialog

> A modal task. Focus moves in, the page behind is inert, Escape closes and focus returns to the trigger.

Category: Overlays · Atomic level: organism · Built on Base UI Dialog
Page: https://ui.dtheo.dev/docs/components/dialog

## Install

```bash
npx dtheo@latest add dialog
# or, with the shadcn CLI
npx shadcn@latest add https://ui.dtheo.dev/r/dialog.json
```

Dependencies: @base-ui/react, clsx, tailwind-merge, lucide-react. Registry dependencies: utils, button.

## Exports

`Dialog`, `DialogTrigger`, `DialogContent`, `DialogHeader`, `DialogTitle`, `DialogDescription`, `DialogFooter`, `DialogClose`

## Use it for

- Short, focused tasks: create, rename, confirm with input

## Reach for something else

- Long forms or side-by-side context: use Sheet
- Destructive confirmations: use Alert dialog

## Keyboard

| Keys | Action |
| --- | --- |
| Escape | Closes the dialog |
| Tab | Cycles focus within the dialog |

## Accessibility

- Every dialog needs a DialogTitle. Inside a ThemeScope it opens in that scope’s theme.

## Examples

### dialog

```tsx
import * as React from 'react';
import { Button } from '@/components/ui/button';
import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from '@/components/ui/dialog';
import { Field, FieldDescription, FieldLabel } from '@/components/ui/field';
import { NumberField } from '@/components/ui/number-field';
import { useToast } from '@/components/ui/toast';

export default function DialogExample() {
  const [open, setOpen] = React.useState(false);
  const toast = useToast();
  return (
    <Dialog open={open} onOpenChange={setOpen}>
      <DialogTrigger render={<Button variant="primary" />}>Queue retune run</DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Queue a retune run</DialogTitle>
          <DialogDescription>
            R-0412 overshot by 17.6 %. Lower the proportional gain and rerun the same step on Bench 3.
          </DialogDescription>
        </DialogHeader>
        <div className="grid grid-cols-2 gap-3">
          <NumberField
            label="Kp"
            defaultValue={3.6}
            step={0.05}
            min={0}
            max={10}
            format={{ minimumFractionDigits: 2 }}
          />
          <NumberField
            label="Kd"
            defaultValue={0.09}
            step={0.01}
            min={0}
            max={1}
            format={{ minimumFractionDigits: 2 }}
          />
        </div>
        <Field>
          <FieldLabel>Bench</FieldLabel>
          <FieldDescription>Bench 3 is free from 15:10.</FieldDescription>
        </Field>
        <DialogFooter>
          <DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
          <Button
            variant="primary"
            onClick={() => {
              setOpen(false);
              toast.add({
                title: 'Retune run queued',
                description: 'R-0413 starts on Bench 3 at 15:10.',
                type: 'success',
              });
            }}
          >
            Queue run
          </Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}
```

## Used in

- Run review (page): https://ui.dtheo.dev/examples/run-review
- Alert dialog (organism): https://ui.dtheo.dev/docs/components/alert-dialog
