Skip to main content
VelinStyle v1.3.0
⌂ Home
  1. Docs
  2. Components
  3. Overlays
  4. Dialog

Dialog 1.2.2

<velin-dialog> wraps the native <dialog> element with a promise-based alert() / confirm() / prompt() API. In 1.2.0 it dispatches canonical velin-close (and keeps deprecated velin-dialog-close as an alias). Deutsch: Dialog De

Maturity: Documented as stable in VelinStyle 1.2.0. Design Intelligence (plan / review / agent meta) is separate and beta / foundation where noted.

When to use

When not

Basic example

<velin-dialog id="myDialog" aria-label="App dialog"></velin-dialog>

<script>
  const dlg = document.getElementById('myDialog');

  // Alert — resolves to true
  await dlg.alert('Hello!');

  // Confirm — resolves to boolean
  const ok = await dlg.confirm('Delete this item?', {
    title: 'Confirm delete',
    danger: true
  });

  // Prompt — resolves to string or null if cancelled
  const name = await dlg.prompt('What is your name?', {
    placeholder: 'Enter name…',
    defaultValue: 'World'
  });

  dlg.addEventListener('velin-close', (e) => {
    console.log('closed with', e.detail.value);
  });
</script>

Accessibility

Dark, responsive, motion, RTL

API

Methods

MethodReturnsDescription
alert(message, options?)Promise<true>Alert dialog
confirm(message, options?)Promise<boolean>Confirm dialog
prompt(message, options?)Promise<string|null>Prompt (null if cancelled)

Options

OptionDefaultDescription
titlevaries by methodTitle text
confirmText"OK" / "Confirm" / "Submit"Confirm label
cancelText"Cancel"Cancel label (confirm/prompt)
dangerfalseDanger-styled confirm (confirm)
placeholder""Prompt placeholder
defaultValue""Prompt default value

Events

EventDetailDescription
velin-close{ value }Canonical close event (ADR 0012) — prefer this
velin-dialog-close{ value }Deprecated alias; still dispatched for one deprecation window

CSS parts & variables

NameDescription
part="dialog"Native dialog element
part="input"Prompt input
--velin-radius-lg, --velin-shadow-xl, --velin-color-surface-bright, --velin-color-border, --velin-color-primary, --velin-color-danger, --velin-color-focusTheming tokens used in shadow styles

Best practices & pitfalls