Skip to content

Modal

A modal dialog for interrupting flows that require user confirmation or input.

Basic usage

Basic usage

Open dialog

This is a basic dialog example.

Controlled visibility

visible is a controlled attribute: the host (button/JS) sets or removes it, and the component never restores it automatically; after closing, listen for oas-ok / oas-cancel and remove visible.

Controlled visibility (visible)

Open (set visible)Close (remove visible)

External buttons set / remove visible to control visibility without relying on the footer buttons.

No footer buttons

Open dialog without footer buttons

The footer action area is hidden; close via ✕ / Esc / mask only.

Disable mask close

Disable mask close

Open dialog

Clicking the mask won't close it; use the buttons or Esc.

Custom width

Custom width

Open dialog with custom width

Specify the dialog width via width, supporting pixels or percentages (e.g. 50%); defaults to 520px when unset.

Vertically centered

Vertically centered

Open vertically centered dialog

By default the dialog is offset toward the top (100px from the top); adding centered centers it vertically.

Draggable

Draggable

Open draggable dialog

Drag the dialog by its title bar; Esc, mask close, and focus behavior stay unchanged.

Event feedback

Event feedback

Open and listen to events

Click "OK" or "Cancel" and watch the message at the top-right.

API

Attributes

AttributeDescriptionTypeDefault
centeredVertically center the dialogboolean
draggableDrag the dialog via its headerboolean
no-footerHide footer action buttonsboolean
no-mask-closeDisable closing on mask clickboolean
titleTitle textstring
visibleWhether shownboolean
widthDialog width (px or percentage)

Events

EventDescription
oas-cancelCancel: cancel button / ✕ / mask click / Esc
oas-okClicked "OK"

Slots

NameDescription
default

role="dialog" + aria-modal="true"; focus moves to the "Cancel" button on open and is restored on close.