Navigated to /docs/ui/components/dialog

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.

TSX
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

Use Dialog for modal workflows that require focused user attention.

Choose something else when

Avoid for simple inline messages; use Alert or Toast.

Examples

Modal content

TSX
tsximport { Dialog } from "@tavojs/ui/dialog";

export function DialogExample1() {
  return (
    <>
      <Dialog open title="Invite teammate">...</Dialog>
    </>
  );
}

Common props and defaults

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
openboolean

Controls whether the dialog is visible.
titleChild

Dialog title.
onCloseTavoEventHandler

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

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by Dialog.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by Dialog.

idstring

No

Inherited id attribute accepted by Dialog.

rolestring

No

Inherited role attribute accepted by Dialog.

styleRecord<string, unknown>

No

Inherited style attribute accepted by Dialog.

titlestring & Child

No

Dialog title.

tabIndexnumber

No

Inherited tabIndex attribute accepted by Dialog.

hiddenboolean

No

Inherited hidden attribute accepted by Dialog.

disabledboolean

No

Inherited disabled attribute accepted by Dialog.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by Dialog.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by Dialog.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by Dialog.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by Dialog.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by Dialog.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by Dialog.

openboolean

No

Controls whether the dialog is visible.

onClose() => void

No

Close callback for escape or dismiss actions where supported.

fullScreenboolean

No

Inherited fullScreen attribute accepted by Dialog.

closeLabelChild

No

Inherited closeLabel attribute accepted by Dialog.

labelledBystring

No

Inherited labelledBy attribute accepted by Dialog.

describedBystring

No

Inherited describedBy attribute accepted by Dialog.

State ownership and DOM target

ConcernContract
StateApplication controlled through open and the matching callback.
DOM targetPublic passthrough props target the component root. Treat nested elements and private class names as implementation details.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

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

ContractCurrent value
Maturitystable
Categoryfeedback
Component import@tavojs/ui/dialog
Explicit CSS import@tavojs/ui/css/dialog
PreviewInteractive preview available on this page