Dialog
Modal dialog with escape handling and focus support.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import the component from its dedicated entry point to keep the dependency and generated bundle explicit.
tsximport { Dialog } from "@tavojs/ui/dialog";Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/dialog.
When to use
Use it when
Choose something else when
Examples
Modal content
tsximport { Dialog } from "@tavojs/ui/dialog";
export function DialogExample1() {
return (
<>
<Dialog open title="Invite teammate">...</Dialog>
</>
);
}Common props and defaults
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
open | boolean | — | Controls whether the dialog is visible. |
title | Child | — | Dialog title. |
onClose | TavoEventHandler | — | Close callback for escape or dismiss actions where supported. |
Complete TypeScript API
Import from @tavojs/ui/dialog. Published exports: Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogProps, DialogRoot.
DialogProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Dialog. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Dialog. |
id | string | No | Inherited id attribute accepted by Dialog. |
role | string | No | Inherited role attribute accepted by Dialog. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Dialog. |
title | string & Child | No | Dialog title. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Dialog. |
hidden | boolean | No | Inherited hidden attribute accepted by Dialog. |
disabled | boolean | No | Inherited disabled attribute accepted by Dialog. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Dialog. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Dialog. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Dialog. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Dialog. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Dialog. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Dialog. |
open | boolean | No | Controls whether the dialog is visible. |
onClose | () => void | No | Close callback for escape or dismiss actions where supported. |
fullScreen | boolean | No | Inherited fullScreen attribute accepted by Dialog. |
closeLabel | Child | No | Inherited closeLabel attribute accepted by Dialog. |
labelledBy | string | No | Inherited labelledBy attribute accepted by Dialog. |
describedBy | string | No | Inherited describedBy attribute accepted by Dialog. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | Application controlled through open and the matching callback. |
| DOM target | Public passthrough props target the component root. Treat nested elements and private class names as implementation details. |
Anatomy and related components
Limitations
Avoid for simple inline messages; use Alert or Toast.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
Uses `role="dialog"`, `aria-modal`, escape close, backdrop close, and tab focus trapping.
Uses `role="dialog"`, `aria-modal`, escape close, backdrop close, and tab focus trapping.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | feedback |
| Component import | @tavojs/ui/dialog |
| Explicit CSS import | @tavojs/ui/css/dialog |
| Preview | Interactive preview available on this page |