Skip to content

Dialog

Open focused content above the page with modal or non-modal behavior.

Usage

Keep focus inside the open dialog and restore it to the trigger when the dialog closes.

Keep focus inside the open dialog and restore it to the trigger when the dialog closes.

Non modal

Leave surrounding content interactive while the dialog remains open.

Leave surrounding content interactive while the dialog remains open.

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

Outside interaction

closeOnInteractOutside controls whether a pointer interaction outside the content closes it. Elements in interactOutsideExclusions stay interactive in a modal and do not count as outside. For conditional decisions, call preventDefault() from the interact-outside event.

template
<DialogRoot
  :interact-outside-exclusions="[ignoredElement]"
  @interact-outside="(event) => {
    if (event.isInside(temporarilyIgnoredElement)) event.preventDefault()
  }"
/>

API

Vue package: @sectile/vue/dialog

Components
  • DialogRoot
  • DialogTrigger
  • DialogPortal
  • DialogOverlay
  • DialogContent
  • DialogTitle
  • DialogDescription
  • DialogClose

Props

DialogRootProps

align

Alignment of positioned content relative to its anchor.

arrowPadding

Minimum space kept between an arrow and the edge of positioned content.

autoFocus

Whether focus moves into the component when it opens.

avoidCollisions

Whether positioned content may flip or shift to remain visible.

closeOnInteractOutside

Whether interaction outside the content closes it.

collisionBoundary

Boundary used to keep positioned content visible.

collisionPadding

Space kept between positioned content and its collision boundary.

defaultOpen

Initial uncontrolled open state.

disabled

Whether interaction is unavailable.

hideWhenDetached

Whether positioned content hides when its anchor leaves the layout.

initialFocus

Element or resolver that receives focus when the component opens.

interactOutsideExclusions

Elements that stay interactive and do not count as outside interaction.

label

Accessible name announced for the control.

modal

Whether open content blocks interaction with the surrounding page.

open

Whether the associated popup or disclosure is open.

restoreFocus

Whether focus returns to the trigger when open content closes.

side

Preferred side of the anchor for positioned content.

sideOffset

Distance between positioned content and its anchor.

strategy

CSS positioning strategy used for anchored content.

tracking

Update strategy used while anchored content is open.

trapFocus

Whether keyboard focus stays inside open content.

unmountOnExit

Whether presence-managed content is removed from the DOM after its exit motion completes.

DialogPartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

DialogPortalProps

defer

Whether Teleport target resolution waits until the end of the current mount or update tick.

disabled

Whether interaction is unavailable.

to

Teleport target for portalled content.

Slots

DialogRootSlotProps

disabled

Whether interaction is unavailable.

open

Whether the associated popup or disclosure is open.

Other types

DialogOpenChangeHandler

ts
type DialogOpenChangeHandler = PopupFactoryOptions['onOpenChange']

DialogInteractOutsideHandler

ts
type DialogInteractOutsideHandler = NonNullable<PopupFactoryOptions['onInteractOutside']>

Parts

Shared scope: [data-scope="dialog"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
trigger[data-part="trigger"]Opens, closes, or activates the associated content.
overlay[data-part="overlay"]Covers surrounding content while a modal surface is open.
content[data-part="content"]Contains the component content shown for the active state.
title[data-part="title"]Labels the associated content.
description[data-part="description"]Describes the associated content or decision.
close[data-part="close"]Closes or dismisses the current surface.

Keyboard interaction

KeyBehavior
Enter / SpaceActivate the trigger or focused action.
Tab / Shift+TabMove through available controls; modal content keeps focus inside.
EscapeClose the popup and restore focus when configured.

Accessibility

The dialog connects title and description, isolates modal background content, traps focus, locks page scroll, and restores focus on close.

See the corresponding WAI-ARIA pattern for the host accessibility contract.

Released under the MIT License.