chrome
<tc-modal>
Modal dialog backed by the native `<dialog>` element. Built-in focus trap, Escape to close, and backdrop dismiss.
import
"@ra9/tan-compose-kit/modal"
Props
| Name | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Whether the dialog is open. Reflects to the host. Set to `true` to show, `false` to close. |
title | string | "" | Optional header title. When empty, the header bar is omitted unless `dismissible` is true. |
dismissible | boolean | true | Allow Escape and backdrop click to close. Disable for confirmation flows that require an explicit choice. |
width | string | "min(560px, 92vw)" | Dialog width. Any CSS length. |
Events
| Event | Detail | When |
|---|---|---|
tc-close | { reason: "backdrop" | "escape" | "button" | "api" } | Fires when the dialog is closed, with the trigger that caused it. |
Slots
| Slot | Description |
|---|---|
(default) | Main body content. |
footer | Action row (e.g. Cancel / Confirm buttons). Rendered with a divider above when present. |
CSS variables
| Variable | Default | Description |
|---|---|---|
--tc-modal-surface | var(--tc-color-surface, #ffffff) | Dialog background. |
--tc-modal-ink | var(--tc-color-ink, #14171f) | Body text color. |
--tc-modal-rule | var(--tc-color-rule, #ece5d3) | Header + footer divider. |
--tc-modal-soft | var(--tc-color-ink-soft, #5a6072) | Close-button color. |
--tc-modal-radius | var(--tc-radius-lg, 12px) | Corner radius. |
--tc-modal-backdrop | rgba(20, 23, 31, 0.5) | Backdrop tint. |
--tc-modal-shadow | var(--tc-shadow-lg, …) | Dialog drop shadow. |
--tc-modal-font | var(--tc-font-sans, …) | Font family. |
Examples
Basic usage
Toggle open to show or hide. The dialog renders into the top layer, above everything else.
Without a title
Omit title for plain prompts. The close button still appears when dismissible is true.
Non-dismissible
For destructive confirmations or required terms-of-service prompts, disable Escape and backdrop closing:
Custom width
Listening for the close reason
Theming
Accessibility
- Built on the native
<dialog>element withshowModal(), so the browser provides focus trapping inside the dialog and inert-ifies the rest of the page. - Escape dismisses the dialog when
dismissibleis true. The close button has anaria-label="Close". - The dialog has
aria-labelledbypointing at the title when present. - Focus returns to the previously-focused element when the dialog closes — handled by the native dialog API.