Skip to content

Dialog

Varo exposes Dialog through composable parts: VDialogRoot, VDialogTrigger, VDialogOverlay, VDialogContent, and VDialogClose.

Demo

Dialog Cross-platform Example and Preview

DialogBrowser dialog flow

When to use

  • Modal confirmations or supplemental content
  • Downstream wrapper composition in an internal design system
  • Shared overlay click and escape close behavior across teams

Anatomy

Dialog is a composed parts model, not one monolithic widget.
  • VDialogRoot owns open state and controlled behavior.
  • VDialogTrigger opens or toggles the dialog.
  • VDialogOverlay handles the backdrop and click-to-close behavior.
  • VDialogContent renders modal content.
  • VDialogClose performs explicit close actions.

Mini-program guidance

For mini-programs, it is usually better to wrap @varo-ui/headless into an internal modal component because platform container differences tend to be larger around overlays and portals. The tabbed example focuses on the shared interaction contract and parts composition.

Root Props

PropTypeDefaultDescription
openboolean | undefinedundefinedControlled open state
defaultOpenbooleanfalseUncontrolled initial state
disabledboolean | undefinedundefinedBlocks open and close behavior

Root Events

EventPayloadDescription
update:openbooleanSync controlled open state
openChangebooleanFires when open state changes

Parts

PartPurpose
VDialogTriggerOpens or toggles the dialog
VDialogOverlayOverlay layer that can close on click
VDialogContentModal content container
VDialogCloseExplicit close action

Behavior

  • supports both controlled and uncontrolled mode
  • supports overlay click close
  • supports Escape close
  • the parts model is a better base for an enterprise modal API than a single rigid component

Composition Guidance

Recommended composition
  • Decide first whether open state belongs to the parent before opting into controlled mode.
  • For more complex dialogs, create a stricter wrapper with header, body, and footer slots instead of repeating raw part assembly everywhere.
  • Keep platform-specific portal decisions in the adapter layer, not in the shared interaction model.

Accessibility and Close Contracts

  • overlay click and Escape close follow the same behavioral contract
  • explicit closing should go through VDialogClose
  • in controlled mode, the parent still decides whether state actually changes