We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

Dialog Component

The Dialog component creates modal overlays that focus user attention on important content or actions. It features a semi-transparent backdrop, smooth animations, and comprehensive accessibility support.

  • Check Circle

    Flexible Positioning: Top, middle, or bottom screen placement

  • Check Circle

    Smooth Animations: Polished transitions for opening and closing

  • Check Circle

    Backdrop Management: Semi-transparent overlay with click-to-close

  • Check Circle

    Focus Management: Maintains proper keyboard focus states

  • Check Circle

    Accessibility: Full ARIA support and keyboard navigation

Create a dialog with a trigger button:

<Button id="open-dialog">Open Dialog</Button>
<Dialog position="middle" triggerQuery="#open-dialog">
<h2>Welcome to the Dialog Component</h2>
<p>This is a live example of the Dialog component in action.</p>
</Dialog>
Dialog Component Props Extends <div> HTMLElement
Prop Type Default Description
position top | middle | bottom middle Vertical position of the dialog
triggerQuery string Query selector for the element that triggers the dialog
closeButtonProps ComponentProps<typeof Button> Props for the close button

The component emits custom events for changes:

document.querySelector('dialog-wrapper').addEventListener(DialogEventNames.Open, (event) => {
// Handle open
});
document.querySelector('dialog-wrapper').addEventListener(DialogEventNames.Close, (event) => {
// Handle close
});
  • Escape to close
  • Tab trap within dialog
  • Return focus on close
Confirmations
Form submissions
Error messages
Success notifications
Terms and conditions

Limited Time Launch Sale

Create engaging user interactions with our pre-built Dialog component. Get the AstroJS starter template now and build better web experiences.

GET 60% OFF!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes