# Dialog
> Dialog displays content that requires user interaction, via a layer that sits on top of the page content.

## Types of dialogs

<Grid
  columns={{
    '@initial': '1',
    '@mqLargeAndUp': '2'
  }}
  rowGap="spacingM"
  columnGap="spacingL"
>
  <GridItem
    css={{
      padding: '$spacingL',
      backgroundColor: '$backgroundNeutral',
      borderRadius: '$m'
    }}
  >
    <VeraCard.Root
      elevated
      borderRadius="m"
      size="small"
      css={{ $$cardBorderColor: 'none' }}
    >
      <VeraCard.Header
        variant="delta"
        as={Flex}
        main="space-between"
        paddingBottom="spacingM"
      >
        Modal header
        <Button
          variant="ghost"
          shape="circle"
          withLoneIcon
          aria-label="Close"
          marginLeft="auto"
          size="small"
        >
          <SvgIcon iconName="close" />
        </Button>
      </VeraCard.Header>
      <VeraCard.Body as={Flex} flow="column">
        <Grid columns="2">
          <GridItem>
            <FormField.Root size="small">
              <FormField.Label>First Name</FormField.Label>
              <TextInput />
            </FormField.Root>
          </GridItem>
          <GridItem>
            <FormField.Root size="small">
              <FormField.Label>Last Name</FormField.Label>
              <TextInput />
            </FormField.Root>
          </GridItem>
        </Grid>
        <Checkbox.Root defaultChecked={false}>
          <Checkbox.Indicator />
          <Checkbox.Label>Remember me</Checkbox.Label>
        </Checkbox.Root>
      </VeraCard.Body>
      <VeraCard.Footer variant="withBackground" as={Flex} main="space-between">
        <Button variant="ghost" size="small">
          Close
        </Button>
        <Button size="small">Submit</Button>
      </VeraCard.Footer>
    </VeraCard.Root>
  </GridItem>
  <GridItem
    as={Flex}
    css={{
      padding: '$spacingL',
      backgroundColor: '$backgroundNeutral',
      borderRadius: '$m'
    }}
  >
    <VeraCard.Root
      elevated
      borderRadius="m"
      size="small"
      css={{ $$cardBorderColor: 'none' }}
    >
      <VeraCard.Body paddingTop="spacingL">
        <Flex
          flow="column"
          cross="center"
          gap="spacingS"
          paddingBottom="spacingM"
        >
          <Dialog.IconCircle>
            <SvgIcon
              iconName="help"
              size="medium"
              color="foregroundNeutralModerate"
            />
          </Dialog.IconCircle>
          <Heading variant="delta" margin="none">
            Confirm action?
          </Heading>
          <Text as="p" marginY="none" color="foregroundNeutralModerate">
            This can not be undone.
          </Text>
        </Flex>
        <Flex main="space-between">
          <Button size="small" variant="ghost">
            Cancel
          </Button>
          <Button size="small">Yes, confirm</Button>
        </Flex>
      </VeraCard.Body>
    </VeraCard.Root>
  </GridItem>
  <GridItem>
    <Link href="/components/dialog#basic">
      <b>Modal dialog</b>
    </Link>
    <br />
    Such dialogs can display more complex data like application forms or
    description of an entity.
  </GridItem>
  <GridItem>
    <Link href="/components/dialog#confirmation-dialog-example">
      <b>Confirmation dialog</b>
    </Link>
    <br />
    This type of dialog is used to request a confirmation of action from a user.
  </GridItem>
</Grid>

<Callout variant="tip">

Just want a text notification? Try [Toaster](/components/toaster) component.

</Callout>

## Import

```js
import { Dialog } from '@gemini-suite/vera-react';

// you may also access Dialog's context via hook:
// import { useDialogContext } from '@gemini-suite/vera-react';
```

Dialog is a compound component that consists of multiple parts to help you create all kinds of dialogs:

- `Dialog.Root`: The wrapper that contains all the parts of a dialog and provides context for its children.
- `Dialog.Trigger`: The button that opens the dialog.
- `Dialog.Box`: The container for the dialog's content.
- `Dialog.Header`: The header of the dialog.
- `Dialog.Title`: The title that labels the dialog.
- `Dialog.Body`: The wrapper that houses the dialog's main content.
- `Dialog.Footer`: The footer that houses the dialog actions.
- `Dialog.Close`: The button that closes the dialog.
- `Dialog.IconCircle`: A decorative icon container used in confirmation dialogs.

## Examples

### Basic

`Dialog` works in an uncontrolled way by default, meaning each `Dialog` component instance is responsible for managing its own state internally.

<Callout variant="tip">

The `Dialog.Trigger` component can be instructed via `as` prop to render _as_ something else. In our case we want to render it as a `<Button>` component.

</Callout>

```jsx
<Dialog.Root>
  <Dialog.Trigger as={Button} variant="outline">
    {'Open Dialog'}
  </Dialog.Trigger>
  <Dialog.Box padding="spacingM">
    {'Dialog content'}
    <Box marginTop="spacingM">
      <Dialog.Close as={Button}>{'Close'}</Dialog.Close>
    </Box>
  </Dialog.Box>
</Dialog.Root>
```

### Controlled Dialog

You can easily make the dialog controlled, by passing your own state to `isOpen` prop.
`onIsOpenChange` handler is called when the state of the dialog changes, allowing you to sync state.

```jsx
() => {
  const [state, setState] = React.useState(false);

  return (
    <Dialog.Root isOpen={state} onIsOpenChange={setState}>
      <Dialog.Trigger as={Button} variant="outline">
        {'Open Dialog'}
      </Dialog.Trigger>
      <Dialog.Box padding="spacingM">
        {'Dialog content'}
        <Box marginTop="spacingM">
          <Dialog.Close as={Button}>{'Close'}</Dialog.Close>
        </Box>
      </Dialog.Box>
    </Dialog.Root>
  );
};
```

### Dialog with header and body

Use `Dialog.Header`, `Dialog.Title`, `Dialog.Close` and `Dialog.Body` parts to construct dialog box with a header and scrollable content.

- `Dialog.Title` takes the title you pass in and labels the dialog with it through ARIA attributes to provide accessible experience.
- `Dialog.Body` ensures that the body of the dialog becomes scrollable when there is not enough space to fit.

```jsx
<Dialog.Root>
  <Dialog.Trigger as={Button} variant="outline">
    {'Open Dialog'}
  </Dialog.Trigger>
  <Dialog.Box>
    <Dialog.Header>
      <Dialog.Title>My dialog</Dialog.Title>
      <Dialog.Close
        as={Button}
        variant="ghost"
        shape="circle"
        withLoneIcon
        aria-label="Close"
        marginLeft="auto"
      >
        <SvgIcon iconName="close" />
      </Dialog.Close>
    </Dialog.Header>
    <Dialog.Body>
      {
        'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
      }
    </Dialog.Body>
  </Dialog.Box>
</Dialog.Root>
```

### Dialog with footer

Use `Dialog.Footer` to add a footer to your dialog and include any action buttons inside.

<Callout variant="tip">

[Stack](/components/Stack) component can be helpful to layout the buttons.

</Callout>

```jsx
<Dialog.Root>
  <Dialog.Trigger as={Button} variant="outline">
    {'Open Dialog'}
  </Dialog.Trigger>
  <Dialog.Box>
    <Dialog.Header>
      <Dialog.Title>My dialog</Dialog.Title>
      <Dialog.Close
        as={Button}
        variant="ghost"
        shape="circle"
        withLoneIcon
        aria-label="Close"
        marginLeft="auto"
      >
        <SvgIcon iconName="close" />
      </Dialog.Close>
    </Dialog.Header>
    <Dialog.Body>
      {
        'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
      }
    </Dialog.Body>
    <Dialog.Footer>
      <Flex>
        <Dialog.Close as={Button} variant="ghost">
          {'Close'}
        </Dialog.Close>
        <Flex marginLeft="auto">
          <Button variant="outline">{'Secondary action'}</Button>
          <Button onClick={() => alert('Primary action triggered')}>
            {'Primary action'}
          </Button>
        </Flex>
      </Flex>
    </Dialog.Footer>
  </Dialog.Box>
</Dialog.Root>
```

### Dialog with dividers

Use `withDividers` prop on `Dialog.Body` to add subtle dividers between dialog sections.

```jsx
<Dialog.Root>
  <Dialog.Trigger as={Button} variant="outline">
    {'Open Dialog'}
  </Dialog.Trigger>
  <Dialog.Box>
    <Dialog.Header>
      <Dialog.Title>My dialog</Dialog.Title>
      <Dialog.Close
        as={Button}
        variant="ghost"
        shape="circle"
        withLoneIcon
        aria-label="Close"
        marginLeft="auto"
      >
        <SvgIcon iconName="close" />
      </Dialog.Close>
    </Dialog.Header>
    <Dialog.Body withDividers>
      <Text as="p">
        {
          'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
        }
      </Text>
      <Text as="p" marginBottom="none">
        {
          'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
        }
      </Text>
    </Dialog.Body>
    <Dialog.Footer>
      <Button marginLeft="auto">{'Save changes'}</Button>
    </Dialog.Footer>
  </Dialog.Box>
</Dialog.Root>
```

Use `useHasOverflow` hook to dynamically apply dividers only when content overflows `Dialog.Body` area.

```js
import { useHasOverflow } from '@gemini-suite/vera-react';
```

```jsx
() => {
  const maxCount = 8;
  const minCount = 1;
  const [count, setCount] = React.useState(2);
  const increment = () => setCount(c => Math.min(c + 1, maxCount));
  const decrement = () => setCount(c => Math.max(c - 1, minCount));

  const [bodyRef, _hasBodyHorizontalScroll, hasBodyVerticalScroll] =
    useHasOverflow();

  return (
    <Dialog.Root>
      <Dialog.Trigger as={Button} variant="outline">
        {'Open Dialog'}
      </Dialog.Trigger>
      <Dialog.Box>
        <Dialog.Header>
          <Dialog.Title>My dialog</Dialog.Title>
          <Dialog.Close
            as={Button}
            variant="ghost"
            shape="circle"
            withLoneIcon
            aria-label="Close"
            marginLeft="auto"
          >
            <SvgIcon iconName="close" />
          </Dialog.Close>
        </Dialog.Header>
        <Dialog.Body ref={bodyRef} withDividers={hasBodyVerticalScroll}>
          <Flex flow="column">
            {Array.from({ length: count }, (_, i) => (
              <FakeText key={i} words="50" />
            ))}
          </Flex>
        </Dialog.Body>
        <Dialog.Footer>
          <Flex>
            <Button
              leftIcon={<SvgIcon iconName="add" />}
              variant="outline"
              onClick={increment}
              isDisabled={count === maxCount}
            >
              {'Add content'}
            </Button>
            <Button
              leftIcon={<SvgIcon iconName="minus" />}
              variant="outline"
              onClick={decrement}
              isDisabled={count === minCount}
            >
              {'Remove content'}
            </Button>
          </Flex>
        </Dialog.Footer>
      </Dialog.Box>
    </Dialog.Root>
  );
};
```

### Sizes

Use `size` prop to control the size of the `Dialog`. `medium` and `small` sizes are available, with the `medium` size used by default.

```jsx
<Flex flow="column" cross="start">
  <Dialog.Root size="small">
    <Dialog.Trigger as={Button} variant="outline" size="small">
      {'Open small dialog'}
    </Dialog.Trigger>
    <Dialog.Box>
      <Dialog.Header>
        <Dialog.Title>{'My small dialog'}</Dialog.Title>
        <Dialog.Close
          as={Button}
          variant="ghost"
          shape="circle"
          withLoneIcon
          aria-label="Close"
          marginLeft="auto"
        >
          <SvgIcon iconName="close" />
        </Dialog.Close>
      </Dialog.Header>
      <Dialog.Body withDividers>
        {
          'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
        }
      </Dialog.Body>
      <Dialog.Footer>
        <Flex>
          <Dialog.Close as={Button} variant="ghost">
            {'Close'}
          </Dialog.Close>
          <Flex marginLeft="auto" gap="spacingS">
            <Button variant="outline">{'Secondary action'}</Button>
            <Button onClick={() => alert('Primary action triggered')}>
              {'Primary action'}
            </Button>
          </Flex>
        </Flex>
      </Dialog.Footer>
    </Dialog.Box>
  </Dialog.Root>
  <Dialog.Root>
    <Dialog.Trigger as={Button} variant="outline">
      {'Open medium dialog'}
    </Dialog.Trigger>
    <Dialog.Box>
      <Dialog.Header>
        <Dialog.Title>{'My medium dialog'}</Dialog.Title>
        <Dialog.Close
          as={Button}
          variant="ghost"
          shape="circle"
          withLoneIcon
          aria-label="Close"
          marginLeft="auto"
        >
          <SvgIcon iconName="close" />
        </Dialog.Close>
      </Dialog.Header>
      <Dialog.Body withDividers>
        {
          'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
        }
      </Dialog.Body>
      <Dialog.Footer>
        <Flex>
          <Dialog.Close as={Button} variant="ghost">
            {'Close'}
          </Dialog.Close>
          <Flex marginLeft="auto">
            <Button variant="outline">{'Secondary action'}</Button>
            <Button onClick={() => alert('Primary action triggered')}>
              {'Primary action'}
            </Button>
          </Flex>
        </Flex>
      </Dialog.Footer>
    </Dialog.Box>
  </Dialog.Root>
</Flex>
```

### Customizable width

Use `width` prop to customize width of the `Dialog.Box`. It will act as a maximum width of the dialog, but if the viewport width is less than that, the dialog will shrink accordingly.

```jsx
<Dialog.Root>
  <Dialog.Trigger as={Button} variant="outline">
    {'Open Dialog'}
  </Dialog.Trigger>
  <Dialog.Box width="20rem">
    <Dialog.Header>
      <Dialog.Title>My dialog</Dialog.Title>
      <Dialog.Close
        as={Button}
        variant="ghost"
        shape="circle"
        withLoneIcon
        aria-label="Close"
        marginLeft="auto"
      >
        <SvgIcon iconName="close" />
      </Dialog.Close>
    </Dialog.Header>
    <Dialog.Body>
      {
        'Smoked tofu homemade balsamic sesame soba noodles portobello mushrooms creamy cauliflower alfredo thyme blackberries Italian pepperoncini basil blood orange smash sriracha pecans lime summer eating together dark chocolate ultimate lavender lemonade dark and stormy mediterranean vegetables black bean wraps hot Malaysian arugula salad.'
      }
    </Dialog.Body>
  </Dialog.Box>
</Dialog.Root>
```

### Confirmation dialog example

```jsx
() => {
  const [isSmallDialogOpen, setIsSmallDialogOpen] = React.useState(false);
  const [isMediumDialogOpen, setIsMediumDialogOpen] = React.useState(false);

  return (
    <Flex flow="column" cross="start">
      <Dialog.Root
        size="small"
        isOpen={isSmallDialogOpen}
        onIsOpenChange={setIsSmallDialogOpen}
      >
        <Dialog.Trigger as={Button} variant="outline" size="small">
          {'Small confirmation dialog'}
        </Dialog.Trigger>
        <Dialog.Box
          width="22rem"
          padding="spacingM"
          shouldCloseOnOverlayClick={false}
        >
          <Flex
            flow="column"
            cross="center"
            gap="spacingS"
            paddingTop="spacingS"
            paddingBottom="spacingM"
          >
            <Dialog.IconCircle>
              <SvgIcon iconName="help" size="medium" />
            </Dialog.IconCircle>
            <Dialog.Title>Delete these 5 events?</Dialog.Title>
            <Text as="p" marginY="none" color="foregroundNeutralModerate">
              {'This can not be undone.'}
            </Text>
          </Flex>
          <Flex main="space-between">
            <Dialog.Close as={Button} variant="ghost">
              {'Cancel'}
            </Dialog.Close>
            <Button color="danger" onClick={() => setIsSmallDialogOpen(false)}>
              {'Yes, delete'}
            </Button>
          </Flex>
        </Dialog.Box>
      </Dialog.Root>
      <Dialog.Root
        isOpen={isMediumDialogOpen}
        onIsOpenChange={setIsMediumDialogOpen}
      >
        <Dialog.Trigger as={Button} variant="outline">
          {'Medium confirmation dialog'}
        </Dialog.Trigger>
        <Dialog.Box
          width="22rem"
          padding="spacingL"
          shouldCloseOnOverlayClick={false}
        >
          <Flex
            flow="column"
            cross="center"
            paddingTop="spacingS"
            paddingBottom="spacingL"
          >
            <Dialog.IconCircle color="success">
              <SvgIcon iconName="validation" size="medium" />
            </Dialog.IconCircle>
            <Dialog.Title>Success!</Dialog.Title>
            <Text as="p" marginY="none" color="foregroundNeutralModerate">
              {'Asset has been created successfully.'}
            </Text>
          </Flex>
          <Flex main="end">
            <Button onClick={() => setIsMediumDialogOpen(false)}>
              {'Continue'}
            </Button>
          </Flex>
        </Dialog.Box>
      </Dialog.Root>
    </Flex>
  );
};
```

### Confirmation on dialog hide

You can prevent users from accidentally closing a dialog with unsaved changes by displaying a nested confirmation dialog.
This can be achieved by preventing the default close behavior and programmatically opening a controlled, nested dialog.

```jsx
() => {
  const [value, setValue] = React.useState('');
  const [isPostOpen, setIsPostOpen] = React.useState(false);
  const [isConfirmationOpen, setIsConfirmationOpen] = React.useState(false);

  // reset post value
  if (!isPostOpen && value) {
    setValue('');
  }

  const handleValueChange = event => setValue(event.target.value);

  const handlePostDialogClose = event => {
    if (value) {
      event.preventDefault();
      setIsConfirmationOpen(true);
    }
  };

  return (
    <Dialog.Root isOpen={isPostOpen} onIsOpenChange={setIsPostOpen}>
      <Dialog.Trigger as={Button} variant="outline">
        {'Post message'}
      </Dialog.Trigger>
      <Dialog.Box
        width="24rem"
        onPointerDownOutside={handlePostDialogClose}
        onEscapeKeyDown={handlePostDialogClose}
      >
        <Dialog.Header>
          <Dialog.Title>{'Post message'}</Dialog.Title>
          <Dialog.Close
            as={Button}
            variant="ghost"
            shape="circle"
            onClick={handlePostDialogClose}
            withLoneIcon
            aria-label="Close"
            marginLeft="auto"
          >
            <SvgIcon iconName="close" />
          </Dialog.Close>
        </Dialog.Header>
        <Dialog.Body withDividers>
          <form
            onSubmit={event => {
              event.preventDefault();
              setIsPostOpen(false);
            }}
          >
            <Flex flow="column">
              <Textarea
                value={value}
                onChange={handleValueChange}
                aria-label="Message"
                placeholder="Leave something here…"
                autoResize
              />
              <Button type="submit" className="txtC">
                {'Post'}
              </Button>
            </Flex>
          </form>
        </Dialog.Body>
      </Dialog.Box>
      <Dialog.Root
        isOpen={isConfirmationOpen}
        onIsOpenChange={setIsConfirmationOpen}
      >
        <Dialog.Box
          width="22rem"
          padding="spacingL"
          shouldCloseOnOverlayClick={false}
        >
          <Flex
            flow="column"
            cross="center"
            paddingTop="spacingS"
            paddingBottom="spacingL"
          >
            <Dialog.IconCircle>
              <SvgIcon iconName="help" size="medium" />
            </Dialog.IconCircle>
            <Dialog.Title variant="delta">Save draft?</Dialog.Title>
            <Text as="p" marginY="none" color="foregroundNeutralModerate">
              {'Draft can be saved for sending message later.'}
            </Text>
          </Flex>
          <Flex main="space-between">
            <Dialog.Close
              as={Button}
              variant="ghost"
              onClick={() => setIsPostOpen(false)}
            >
              {'Discard'}
            </Dialog.Close>
            <Dialog.Close as={Button} onClick={() => setIsPostOpen(false)}>
              {'Save draft'}
            </Dialog.Close>
          </Flex>
        </Dialog.Box>
      </Dialog.Root>
    </Dialog.Root>
  );
};
```

---

## Accessibility features

<ul>
  <li iconName="check">

When the dialog opens, focus is sent into the dialog and set to the first tabbable element. Focus stays trapped within the dialog until close is requested. After closing, focus is restored back to the trigger element.

  </li>
  <li iconName="check">

Clicking on the overlay closes the dialog.

  </li>
  <li iconName="check">

Pressing ESC closes the dialog.

  </li>
  <li iconName="check">

Scrolling is blocked on the elements behind the dialog.

  </li>
  <li iconName="check">

The dialog is portaled (via [Portal utility](/components/utility/portal)) to the end of `document.body` to break it out of the source order.

  </li>
  <li iconName="check">

Manages screen reader announcements with `Dialog.Title`.

  </li>
</ul>

---

## API Reference

### Dialog.Root

| Name             | Type                        | Default    | Description                                                                                            | Required |
| ---------------- | --------------------------- | ---------- | ------------------------------------------------------------------------------------------------------ | -------- |
| `isOpen`         | `boolean`                   | `false`    | The controlled open state of the dialog. Use in conjunction with `onIsOpenChange`.                     |          |
| `defaultIsOpen`  | `boolean`                   |            | The open state of the dialog when it's first rendered. Use when you do not need to control open state. |          |
| `onIsOpenChange` | `(isOpen: boolean) => void` |            | Event handler called when the open state of the dialog changes.                                        |          |
| `size`           | `"medium" \| "small"`       | `"medium"` | The size of the dialog.                                                                                |          |

### Dialog.Trigger

| Name  | Type                                                      | Default  | Description                                                                                                                                                                                                                                                                                  | Required |
| ----- | --------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `as`  | `keyof JSX.IntrinsicElements \| React.ComponentType<any>` | `button` | Change the component to a different HTML tag or custom component. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.   For more details, read our [Composition](/get-started/composition#polymorphism) guide. |          |
| `css` | `StitchesCss`                                             |          | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants.                                                |          |

### Dialog.Box

| Name                        | Type                             | Default      | Description                                                                                                                                                                                                                                   | Required |
| --------------------------- | -------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `css`                       | `StitchesCss`                    |              | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants. |          |
| `width`                     | `string \| number`               | `"38rem"`    | Width of the dialog box. Acts as a maximum width: when larger than viewport, the dialog will shrink accordingly.                                                                                                                              |          |
| `padding`                   | `SpacingToken`                   |              | Sets `padding` to one of the corresponding [spacing tokens](/tokens/white-space).                                                                                                                                                             |          |
| `zIndex`                    | `number`                         |              | Can be used to override default `z-index` of the dialog when absolutely needed.                                                                                                                                                               |          |
| `onExitComplete`            | `() => void`                     | `() => void` | Event handler called when the dialog has completed animating out.                                                                                                                                                                             |          |
| `onPointerDownOutside`      | `(event: Event) => void`         |              | Event handler called when a pointer event occurs outside the bounds of the dialog box. It can be prevented with `event.preventDefault`.                                                                                                       |          |
| `onEscapeKeyDown`           | `(event: KeyboardEvent) => void` |              | Event handler called when the escape key is down. It can be prevented with `event.preventDefault`.                                                                                                                                            |          |
| `shouldCloseOnOverlayClick` | `boolean`                        | `true`       | When `true`, the dialog box will close when the overlay is clicked.                                                                                                                                                                           |          |
| `shouldCloseOnEsc`          | `boolean`                        | `true`       | When `true`, the dialog box will close when the `Esc` key is pressed.                                                                                                                                                                         |          |

### Dialog.Header

<Callout variant="tip">

In addition to the props below, you can pass [Box props](/components/layout/box#api-reference) to control the spacing.

</Callout>

| Name  | Type          | Default | Description                                                                                                                                                                                                                                   | Required |
| ----- | ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `css` | `StitchesCss` |         | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants. |          |

### Dialog.Title

<Callout variant="tip">

In addition to the props below, you can pass [Heading props](/components/typography/heading#api-reference).

</Callout>

| Name  | Type                                                      | Default  | Description                                                                                                                                                                                                                                                                                  | Required |
| ----- | --------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `as`  | `keyof JSX.IntrinsicElements \| React.ComponentType<any>` | `button` | Change the component to a different HTML tag or custom component. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.   For more details, read our [Composition](/get-started/composition#polymorphism) guide. |          |
| `css` | `StitchesCss`                                             |          | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants.                                                |          |

### Dialog.Body

<Callout variant="tip">

In addition to the props below, you can pass [Box props](/components/layout/box#api-reference) to control the spacing.

</Callout>

| Name           | Type          | Default | Description                                                                                                                                                                                                                                   | Required |
| -------------- | ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `css`          | `StitchesCss` |         | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants. |          |
| `withDividers` | `boolean`     | `false` | Displays the top and bottom dividers.                                                                                                                                                                                                         |          |

### Dialog.Footer

<Callout variant="tip">

In addition to the props below, you can pass [Box props](/components/layout/box#api-reference) to control the spacing.

</Callout>

| Name  | Type          | Default | Description                                                                                                                                                                                                                                   | Required |
| ----- | ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `css` | `StitchesCss` |         | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants. |          |

### Dialog.Close

| Name  | Type                                                      | Default  | Description                                                                                                                                                                                                                                                                                  | Required |
| ----- | --------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `as`  | `keyof JSX.IntrinsicElements \| React.ComponentType<any>` | `button` | Change the component to a different HTML tag or custom component. This will merge the original component props with the props of the supplied element/component and change the underlying DOM node.   For more details, read our [Composition](/get-started/composition#polymorphism) guide. |          |
| `css` | `StitchesCss`                                             |          | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants.                                                |          |

### Dialog.IconCircle

| Name    | Type                                                        | Default     | Description                                                                                                                                                                                                                                   | Required |
| ------- | ----------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `css`   | `StitchesCss`                                               |             | Apply styles directly to a component in a similar way how you would define inline styles. Vera uses [Stitches](https://stitches.dev/) under the hood with a fully-typed API and support for features like tokens, media queries, or variants. |          |
| `color` | `"neutral" \| "success" \| "danger" \| "info" \| "warning"` | `"neutral"` | The color of the icon container.                                                                                                                                                                                                              |          |
