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.

Fullscreen dialog

fullscreen makes the dialog fill the viewport (no radius, no margin). Precedence: fullscreen wins over width / centered / draggablewidth is ignored, centered has no layout effect, dragging is disabled; Esc / mask close, focus trap, and ARIA behavior stay the same.

Fullscreen dialog

Open fullscreen dialog

The fullscreen dialog fills the viewport without radius or margin. width / centered are ignored and dragging is disabled; Esc / mask close still work.

Imperative confirm

The imperative confirm() API is Promise-based and reuses oas-modal (returns Promise<void>; resolves on OK, rejects on cancel). Pass an async onOk callback for a loading confirmation: clicking OK puts the OK button into loading (spinner, no repeated triggers); on resolve the dialog closes and the outer promise resolves; on reject the loading clears and the dialog stays open for retry or cancel.

Imperative confirm

Async confirmLoading confirm

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
fullscreenDisplay fullscreen: the dialog fills the viewport without radius or margin (takes precedence over width / centered / draggable)boolean
loadingPut the OK button into loading state (disabled + spinner), blocking repeated confirmsboolean
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.

Released under the MIT OR Apache-2.0 License.