Skip to content

Dialog

SDialog is a modal window built on Reka UI: focus trap, closing on Esc and on an outside click, a portal, and correct ARIA relationships. It is controlled with v-model:open; the trigger is passed through a slot.

Basic usage

Title and close slots

The title, description, and close slots replace the default markup, for example to add an icon to the title and replace the close cross with an SIcon.

Width

The window is 32rem wide by default. The width prop sets a different width as a CSS length or a number of pixels; on a narrow screen the window is still no wider than 92vw. The same width can be set with the --s-dialog-width variable if it is easier to set it from a theme or a class.

The window is rendered in a portal at body, so the class, style, and attributes passed to SDialog land directly on .s-dialog__content: this lets you reach the content without global selectors.

API

Props

NameTypeDefaultDescription
squarebooleanundefinedSquare corners: removes the border radius (rounded by default).
widthstring | numberundefinedWindow width: a CSS length or a number in pixels. On a narrow screen the window is still no wider than 92vw. Without the prop the width comes from the --s-dialog-width variable (32rem by default).
titlestringundefinedDialog title (can be replaced with the title slot).
descriptionstringundefinedDialog description (can be replaced with the description slot).
close-labelstringundefinedAccessible name of the close button (defaults to the locale dictionary).
openbooleanundefinedWhether the dialog is open. Two-way binding via v-model:open.

Events

NameSignatureDescription
update:open(value: boolean | undefined) => voidEmitted when open changes. Used for two-way binding (v-model:open).

Slots

NameDescription
triggerTrigger element that opens the dialog (wrapped in DialogTrigger).
titleDialog title (replaces the title prop).
descriptionDialog description (replaces the description prop).
defaultMain content (body) of the dialog.
footerDialog footer, usually action buttons.
closeContent of the close button ("×" by default).