Skip to main content

Starwind UI v3.0 is now available! Migration guide

Example Dialog

This is a simple dialog example that demonstrates the basic functionality.

Your dialog content goes here.

Installation

Usage

General Notes

All you really need is the Dialog,DialogTrigger, and DialogContent. The rest is up to you. As examples, the search feature and mobile navbar of this site are built on top of the Dialog component.

With Form

Dialogs are commonly used with forms for data input.

Tip

Open up the dev tools console to see the form data on submission.

Edit profile

Make changes to your profile here. Click save when you're done.

Multiple Triggers

You can have multiple triggers open the same dialog, including external triggers outside the Dialog wrapper. Add an id to <Dialog /> and pass that ID through targetId on each external <DialogTrigger />.

Contact Us

Send us a message and we'll get back to you shortly.

This button is outside the Dialog component but opens the same dialog:

Nested Dialogs

New You can nest dialogs within other dialogs to create multi-level workflows. The nested dialog will appear on top of the parent dialog, and only the topmost dialog will close when pressing Escape or clicking outside.

Parent Dialog

This is the parent dialog. You can open a nested dialog from here.

Nested Dialog

This is the nested dialog. The parent will not close when clicking outside.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Dialog Trigger

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Wrapper prop

Dialog Close

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Dialog.

Primitive API

Runtime API

Dialog primitive
createDialog from @starwind-ui/runtime/dialog

Changelog

v2.0.2

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v2.0.0

  • Rebuilt Dialog on Starwind Runtime for modal state, focus management, dismissal, and nesting.
  • See the Dialog Primitive for the underlying unstyled anatomy and behavior API.