# DialogClose

Supply UI 1.1.0. On top of the page, part of `Dialog`.

A task in a window; `drawer` slides in from the right for details, `sheet` rises from the bottom (best on a phone). Everything that opens on top closes with a fade: put what a close button does to the page in `afterClose`, never `onClick`, so it runs once the closing is over (the same on `AlertDialogClose` and `DrawerClose`). Otherwise the page can take the dialog away mid-fade and it just vanishes

Closes the dialog. `afterClose` runs once it has finished closing: use it for anything that changes the page, so the dialog fades out first.

## Options

| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `afterClose` | `() => void` |  | Runs once the dialog has finished closing: for what changes the page in its place, so nothing jumps while it fades. |

It also takes the 292 attributes of the element or UI SDK part it renders (`className`, `aria-label`, events…).

## CSS parts

With the CSS in parts (`/ui/css/`), it needs: `components/card.css`, `components/tabs.css`, `components/dialog.css`, `components/tab-bar.css`, `components/prose.css`, `components/page-transitions.css`, `parts/carousel.css`, `parts/board.css`, besides the ones every page loads.

## In the examples

- Add without leaving: A dialog takes the details; the list grows behind it (https://www.supply.family/ui/#scene-new-client)

## On top of the page: notes

**States.** Closed, opening (fades and rises), open, closing (fades before what it changed appears: `afterClose`). While open, focus is inside and Escape closes it; when it closes, focus goes back to what opened it.

**Do**
- Name every dialog, drawer and popover (`DialogTitle`, `DrawerTitle`, or `aria-label`).
- Use `AlertDialog` for anything that cannot be undone, with the action named on its button ("Delete 3 files").
- Use a `Drawer` on a phone for what a `Popover` does on a computer.

**Don't**
- Don't open a dialog from a dialog; change what the open one shows instead.
- Don't put the only way to do something in a right-click menu or a tooltip.
- Don't use a toast for something the person must not miss: that is an `Alert` on the page.
