# Dialog Behavior

> Shared attributes and focus/Esc behavior inherited by every dialog-based component.

Dialog-based components share one behavior set: lazy mount on first open, teleport to `document.body` (unless `inline`), page scroll lock, a focus trap, Esc to close, and focus restore to the opener.

| Attribute | Effect |
| --- | --- |
| `open` | Open on first render; stays in sync with show/hide. |
| `center` | Vertically center the panel. |
| `container` | Contained overlay presentation. |
| `full` | Full-screen overlay presentation. |
| `stack` | Allow stacked dialogs instead of hiding the others. |
| `inline` | Keep the component in its original DOM position. |
| `no-bg-close` | Ignore clicks on the overlay background. |
| `no-esc-close` | Ignore the Esc key. |
| `unmount` | Remove the rendered DOM after closing. |
| `dialog-role` | Panel role: `dialog` or `alertdialog`. |

```html
<button type="button" class="z-button z-button-primary" data-toggle="#cmd-dialog">Open centered</button>

<z-cmd id="cmd-dialog" center no-esc-close>
  <select data-fn="data-source" hidden>
    <optgroup label="Actions">
      <option value="confirm">Confirm</option>
    </optgroup>
  </select>
</z-cmd>
```

> **Warning:** Esc always acts on the topmost dialog. With `stack`, opening a dialog no longer closes the ones beneath it.
