Skip to content
Viewership Inquire
UI Components

Modal.

Centred dialog on a blurred backdrop, built on native <dialog> for focus trapping and Escape. Backdrop click closes.

OverlaysComponent1 dependency Original, MIT

.md

Send this draft for approval?

The spring trip email goes to the brand lead. They can approve it or leave notes.

Using Claude Code? Give it the agent prompt and skip these steps.

  1. Import the foundation once

    foundation.css holds the tokens every component reads.

    Layout.astro
    ---
    // src/layouts/Layout.astro
    import "../styles/foundation.css";
    ---
  2. Copy Modal.astro

    Paste into src/components/viewership/modal/

  3. Copy its dependencies

    Each in its own folder, next to this one.

  4. Use it

    Page.astro
    ---
    import Modal from "../components/viewership/modal/Modal.astro";
    ---
    
    <Modal />

Props 8

PropTypeDefaultDescription
title string · Dialog heading, also its accessible name.
description string · Line under the title (aria-describedby).
id string · Dialog id. Any element with data-vs-modal-open set to it opens the dialog.
triggerLabel string · Renders a primary button that opens the dialog.
size "sm" | "md" "sm" Dialog width: 440px or 600px.
slot: default slot · Body content.
slot: actions slot · Submit buttons that close the dialog. Their value becomes returnValue.
slot: trigger slot · Custom trigger. Give it data-vs-modal-open with the dialog id.

Events

EventDetailWhen
vs-close CustomEvent<{ value: string }> Fires on close with the returnValue: the action button's value, "dismiss" from the X or backdrop, empty after Escape.

Source 1 file

Original, MIT.