Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Dialog

    Modal dialogs on the native `<dialog>`, opened by invoker commands.

    Installation

    Source
    pnpm dlx zazz-ui add dialog
    npx zazz-ui add dialog
    yarn dlx zazz-ui add dialog
    bunx zazz-ui add dialog

    Run zazz-ui init first if the project has no zazz/ folder yet.

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Paint the right theme (background, form controls, scrollbars) before CSS loads -->
    <meta name="color-scheme" content="light dark">
    <!-- Zazz styles: base layers, then dialog in cascade order -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_layers.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_variables.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_shadows.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_breakpoints.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_reset.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_typography.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_view-transitions.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/primitives/dialog/dialog.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-sm.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-md.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-lg.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-2xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-disabled.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-active.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-visible.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-focus-within.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-hover.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-checked.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-current.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-open.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-stuck.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_properties-starting.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-sm.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-md.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-lg.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-2xl.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-disabled.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-active.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-visible.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-focus-within.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-hover.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-checked.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-current.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-open.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-stuck.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-tier-starting.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-flow.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-grid.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-spacing.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-margin.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sizing.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-typography.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-color.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-effects.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-box.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-pseudo.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_defaults.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/_utilities-sr.css">
    <!-- Import map: bare specifiers in Zazz scripts resolve to pinned, SRI-checked files -->
    <script type="importmap">
    {
      "imports": {
        "signal-polyfill": "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js"
      },
      "integrity": {
        "https://cdn.jsdelivr.net/npm/signal-polyfill@0.2.2/dist/index.js": "sha384-0OqM7OXGT6Oz1z98u/geiFn/FUyz4iWexkXHCvbIGXRRDXl6bp6IKc0j78AQ6DEK"
      }
    }
    </script>
    <!-- Polyfill: Interest Invokers (interestfor) — native in Chromium only -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/invokers@2.2.2/dist/esm/production/interest.js" integrity="sha384-hR2BVNtsS7fIIMwOm+f7MY0JZfuByGhQQfevCBB6evFATKzBsTw0JzH/RxD94z2T" crossorigin="anonymous"></script>
    <!-- Zazz behavior: side-effect modules by tag; the rest via module imports -->
    <script type="module" src="https://cdn.jsdelivr.net/npm/@zazz-ui/core@0.14.2/src/base/dialog-lifecycle.js"></script>
    <!-- Theme: apply the persisted (or preferred) scheme before first paint -->
    <script>
      (() => {
        try {
          // A stored choice pins the scheme with data-theme; with no choice the
          // page follows the system scheme.
          const storedTheme = localStorage.getItem("theme");
          if (storedTheme === "dark" || storedTheme === "light") {
            document.documentElement.dataset.theme = storedTheme;
          }
        } catch {
          /* no storage access: follow the system scheme */
        }
      })();
    </script>

    A <head> that loads the base layers and dialog from jsDelivr, pinned to 0.14.2. To load the whole kit in two requests, see the CDN install.

    Examples

    Default

    Dialog title

    This dialog was opened using an invoker command.

    Set the size of the dialog with the data-dialog-size attribute.

    <button data-ui="button" type="button" command="show-modal" commandfor="dialog-example-1">
      Dialog
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <line
          x1="64"
          y1="192"
          x2="192"
          y2="64"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
        <polyline
          points="88 64 192 64 192 168"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
      </svg>
    </button>
    <dialog id="dialog-example-1" data-ui="dialog" closedby="any">
      <div data-dialog-slot="content">
        <header data-dialog-slot="header">
          <h2
            style="
              --font-size: var(--font-size-lg);
              --font-weight: strong;
              --font-family: var(--font-family-heading);
            "
          >
            Dialog title
          </h2>
          <p style="--text: var(--color-muted-foreground)">
            This dialog was opened using an
            <a
              href="https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API"
              target="_blank"
              style="--text: var(--color-primary)"
              >invoker command</a
            >.
          </p>
        </header>
        <div data-dialog-slot="body">
          <p>Set the size of the dialog with the <code>data-dialog-size</code> attribute.</p>
        </div>
        <footer data-dialog-slot="footer">
          <button data-ui="button" type="button" commandfor="dialog-example-1" command="close">
            Cancel
          </button>
          <button
            data-ui="button"
            data-button-variant="primary"
            commandfor="dialog-example-1"
            command="close"
          >
            Accept
          </button>
        </footer>
      </div>
      <button
        data-ui="button"
        data-dialog-slot="close"
        data-button-size="icon"
        data-button-variant="ghost"
        type="button"
        commandfor="dialog-example-1"
        command="close"
      >
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
          <rect width="256" height="256" fill="none" />
          <line
            x1="200"
            y1="56"
            x2="56"
            y2="200"
            stroke="currentColor"
            stroke-linecap="round"
            stroke-linejoin="round"
            stroke-width="16"
          />
          <line
            x1="200"
            y1="200"
            x2="56"
            y2="56"
            stroke="currentColor"
            stroke-linecap="round"
            stroke-linejoin="round"
            stroke-width="16"
          />
        </svg>
      </button>
    </dialog>
    /**
     * dialog.css — Dialog ([data-ui~="dialog"] on native <dialog>; slots
     *             data-dialog-slot="content | header | body | footer | close")
     *
     * @layer      variables, reset, components
     * @requires   _layers.css, _variables.css, _properties.css (--_*-resolved)
     * @uses       <dialog>, ::backdrop — native modal + backdrop
     * @uses       :root:has(dialog:modal) — overflow: hidden + scrollbar-gutter: stable while a modal
     *             is open (WebKit ignores overscroll-behavior on boxes that do not overflow)
     * @uses       @starting-style + allow-discrete — open/close opacity, transform, overlay
     * @uses       anchor-name, container-type — layout hooks for sized variants
     * @uses       corner-shape — superellipse corners; unsupported browsers keep plain
     *             rounded corners
     * @tokens     --ui-dialog-* (@layer variables; --ui-dialog-h defaults to a keyword, so the hook
     *             is read raw and takes a length or keyword; a --h utility or tier takes a scale
     *             number or a length; a keyword tier needs a base --h, or it renders as auto)
     * @presets    data-dialog-size="sm | md | lg | xl | 2xl | full | bleed" (the layout bands; sm when absent)
     * @uses       @media (width < 40rem) and (not (hover: hover)) + @container style(--ui-dialog-mobile-size)
     *             — below the sm band on a touch screen every dialog takes the hook's size (layout-bleed
     *             by default) over its preset; a narrow window with a mouse keeps the preset; style
     *             queries are Firefox 151+, Chrome 111+, Safari 18+, an older engine keeps the preset
     * @uses       env(safe-area-inset-bottom) — the full-height content slot clears the home indicator
     * @uses       translate, scale — in the transition list for consumers that move a dialog with
     *             them (drawer.js drags with an inline translate and releases into these
     *             transitions; a drawer behind another is scaled back)
     * @consumedby alert-dialog.css, command.css, drawer.css, lightbox.css, mobile-menu.css
     */
    
    @layer variables {
      :root {
        --ui-dialog-backdrop-color: var(--color-shade-900);
        --ui-dialog-transition-duration: var(--default-transition-duration);
        --ui-dialog-transition-timing-function: var(--default-transition-timing-function);
        --ui-dialog-backdrop-transition-duration: calc(var(--ui-dialog-transition-duration) / 2);
        --ui-dialog-backdrop-transition-timing-function: var(--bezier-easing);
        --ui-dialog-backdrop-filter: none;
        --ui-dialog-shadow: var(--shadow-lg);
        --ui-dialog-border-width: 1px;
        --ui-dialog-border-style: solid;
        --ui-dialog-border-color: var(--color-border);
        /* the sm band, the default size */
        --ui-dialog-w: min(var(--layout-sm), 100% - var(--gutters) * 2);
        /* below the sm band, the size every dialog takes: layout-bleed (edge to edge, no page
           behind it), layout-full (inside the gutters), or none (its own preset) */
        --ui-dialog-mobile-size: layout-bleed;
    
        /* Reveal transitions/animations */
        --ui-dialog-opacity--start: 0;
        --ui-dialog-opacity--end: 1;
        --ui-dialog-scale--start: 0.98;
        --ui-dialog-scale--end: 1;
        --ui-dialog-translate--start: 0, 0, 0;
        --ui-dialog-translate--end: 0, 0, 0;
        --ui-dialog-transition-delay--start: 0ms;
        --ui-dialog-transition-delay--end: 0ms;
      }
    }
    
    @layer variables {
      :root {
        --ui-dialog-h: fit-content;
        --ui-dialog-bg: var(--color-card);
        --ui-dialog-text: var(--color-card-foreground);
        --ui-dialog-radius: var(--radius-lg);
        --ui-dialog-corner-shape: var(--radius-corner-shape);
      }
    }
    
    @layer reset {
      /* ===========================================================================
      DIALOG — native <dialog> open/close animation, sizing, backdrop fade
      - In the reset layer so the dialog component styling below wins.
      =========================================================================== */
    
      /* Spring-eased open/close */
      :where(dialog) {
        isolation: isolate;
        margin: auto;
        max-inline-size: calc(100% - var(--space-md));
        max-block-size: calc(100% - var(--space-md));
        border: var(--ui-dialog-border-width) var(--ui-dialog-border-style)
          var(--ui-dialog-border-color);
        contain: layout style;
        opacity: var(--ui-dialog-opacity--start);
        box-shadow: var(--ui-dialog-shadow);
        overscroll-behavior: contain;
        overflow: hidden;
        transform: translate3d(var(--ui-dialog-translate--start)) scale(var(--ui-dialog-scale--start));
        transition:
          opacity var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          transform var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          translate var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          scale var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          padding var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          block-size var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          inline-size var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          overlay var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function)
            allow-discrete,
          display var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function)
            allow-discrete;
        transition-delay: var(--ui-dialog-transition-delay--start);
      }
    
      :where(dialog[open]) {
        transform: translate3d(var(--ui-dialog-translate--end)) scale(var(--ui-dialog-scale--end));
        opacity: var(--ui-dialog-opacity--end);
        transition-delay: var(--ui-dialog-transition-delay--end);
    
        @starting-style {
          transition-delay: var(--ui-dialog-transition-delay--start);
          transform: translate3d(var(--ui-dialog-translate--start)) scale(var(--ui-dialog-scale--start));
          opacity: var(--ui-dialog-opacity--start);
        }
      }
    
      /* Backdrop fades via a discrete transition. Twice the viewport tall: with the
         software keyboard up, iOS shows the page below the rect fixed boxes fill, and a
         fixed box past the viewport edge creates no scroll. */
      :where(dialog)::backdrop {
        position: fixed;
        inline-size: 100%;
        block-size: 100%;
        inset: 0;
        opacity: 0;
        overscroll-behavior: contain;
        overflow: clip;
        background-color: var(--ui-dialog-backdrop-color);
        backdrop-filter: var(--ui-dialog-backdrop-filter);
        transition: opacity var(--ui-dialog-backdrop-transition-duration)
          var(--ui-dialog-backdrop-transition-timing-function);
      }
    
      :where(dialog[open])::backdrop {
        opacity: 1;
    
        @starting-style {
          opacity: 0;
        }
      }
    
      /* Chromium and Firefox contain page scroll through overscroll-behavior above; WebKit
         ignores it on a box that does not overflow (the backdrop, a short dialog), so the root
         locks while a modal is open. The gutter stays the width of the scrollbar it replaces,
         so neither the page nor the centred dialog shifts on open or on close; the scroll
         position survives. At rest no gutter is reserved. */
      :root:has(dialog:modal) {
        overflow: hidden;
        scrollbar-gutter: stable;
      }
    }
    
    /* Size privates: written by data-dialog-size, non-inheriting. */
    @property --_dialog-w {
      syntax: "*";
      inherits: false;
    }
    
    @property --_dialog-h-typed {
      syntax: "*";
      inherits: false;
    }
    @property --_dialog-h {
      syntax: "*";
      inherits: false;
    }
    
    @property --_dialog-radius {
      syntax: "*";
      inherits: false;
    }
    
    @property --_dialog-shadow {
      syntax: "*";
      inherits: false;
    }
    
    @layer ui.components {
      :where([data-ui~="dialog"]) {
        /* Set the hook on the element (not :root) so a later consumer (alert-dialog)
           or a subtree hook still wins; --_dialog-shadow is written only by the
           bleed preset. */
        --ui-dialog-shadow: var(--shadow-md);
    
        --_w-len: var(--_w-resolved, var(--_dialog-w, var(--ui-dialog-w)));
        --_w-num: var(--_w-resolved, var(--_dialog-w, var(--ui-dialog-w)));
        inline-size: calc(var(--_w-len) + var(--_w-num) * var(--spacing));
        /* The typed pair can't carry the hook's keyword. sign() adds nothing to the sum:
           its var() leaves --_dialog-h-typed unset without a --h, so the chain reaches the hook */
        --_h-len: var(--_h-resolved);
        --_h-num: var(--_h-resolved);
        --_dialog-h-typed: calc(
          var(--_h-len) + var(--_h-num) * var(--spacing) + 0px * sign(var(--_h-resolved))
        );
        block-size: var(--_dialog-h-typed, var(--_dialog-h, var(--ui-dialog-h)));
        background-color: var(--_bg-resolved, var(--ui-dialog-bg));
        color: var(--_text-resolved, var(--ui-dialog-text));
        box-shadow: var(--_shadow-resolved, var(--_dialog-shadow, var(--ui-dialog-shadow)));
        --_radius-len: var(--_radius-resolved, var(--_dialog-radius, var(--ui-dialog-radius)));
        --_radius-num: var(--_radius-resolved, var(--_dialog-radius, var(--ui-dialog-radius)));
        border-radius: calc(
          var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
        );
        corner-shape: var(--_corner-shape-resolved, var(--ui-dialog-corner-shape));
    
        anchor-name: --ui-dialog-root;
        container-type: inline-size;
        container-name: dialog;
        font-size: var(--font-size-md);
        isolation: isolate;
        overflow: auto;
        overscroll-behavior: contain;
      }
    
      /* A one-row grid, so the content slot is capped by the dialog's height rather than
         sizing it (display went missing with the --ui-dialog-display token in 0.2). */
      :where([data-ui~="dialog"][open]) {
        display: grid;
        grid-template-rows: minmax(0, 1fr);
        min-block-size: 0;
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="close"] {
        position: absolute;
        inset-block-start: var(--space-xs);
        inset-inline-end: var(--space-xs);
        z-index: 50;
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="close"] > svg {
        inline-size: calc(var(--spacing) * 4);
        block-size: calc(var(--spacing) * 4);
        pointer-events: none;
        justify-content: center;
        align-items: center;
        display: flex;
        padding: 0;
      }
    
      /* Each slot owns a row, whatever the order and whichever are present: a body on its
         own still takes the flexible row, so it is the part that scrolls, never the dialog,
         and the close button keeps its corner. */
      :where([data-ui~="dialog"]) [data-dialog-slot~="content"] {
        display: grid;
        align-self: center;
        grid-template-rows: auto minmax(0, 1fr) auto;
        position: relative;
        min-block-size: 0;
        max-block-size: 100%;
        overscroll-behavior: contain;
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="header"] {
        grid-row: 1;
        display: flex;
        flex-direction: column;
        padding-inline: var(--space-sm);
        padding-block-start: var(--space-sm);
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="body"] {
        --_scroll-fade-gradient: linear-gradient(
          to bottom,
          transparent 0,
          #000 var(--_scroll-fade-start),
          #000 calc(100% - var(--_scroll-fade-end)),
          transparent 100%
        );
    
        grid-row: 2;
        display: grid;
        /* a full-height body keeps its rows at the top rather than spreading them */
        align-content: start;
        padding-inline: var(--space-sm);
        padding-block: var(--space-md);
        min-block-size: fit-content;
        max-block-size: 100%;
        overscroll-behavior: contain;
        overflow-y: auto;
    
        -webkit-mask-image: var(--ui-scroll-fade-mask, var(--_scroll-fade-gradient));
        mask-image: var(--ui-scroll-fade-mask, var(--_scroll-fade-gradient));
        -webkit-mask-composite: source-in;
        mask-composite: intersect;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
    
        @supports (animation-timeline: scroll()) {
          animation:
            ui-scroll-fade-reveal-start 1ms ease-in-out,
            ui-scroll-fade-reveal-end 1ms ease-in-out;
        }
    
        @supports not (animation-timeline: scroll()) {
          --_scroll-fade-start: var(--ui-scroll-fade-size);
          --_scroll-fade-end: var(--ui-scroll-fade-size);
        }
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="footer"] {
        grid-row: 3;
        block-size: fit-content;
        inset-block-end: 0;
        display: flex;
        justify-content: flex-end;
        align-self: end;
        flex-shrink: 0;
        gap: var(--space-xs);
        padding: var(--space-sm);
        border-block-start: 1px solid var(--color-border);
        background-color: var(--ui-dialog-bg);
      }
    
      /* Sizes follow the layout bands: sm … 2xl cap the width at the band (sm is the
         default), full spans the viewport inside the gutters, bleed fills it edge to edge. */
      :where([data-ui~="dialog"][data-dialog-size="sm"]) {
        --_dialog-w: min(var(--layout-sm), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="md"]) {
        --_dialog-w: min(var(--layout-md), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="lg"]) {
        --_dialog-w: min(var(--layout-lg), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="xl"]) {
        --_dialog-w: min(var(--layout-xl), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="2xl"]) {
        --_dialog-w: min(var(--layout-2xl), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="full"]) {
        --_dialog-w: calc(100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="bleed"]) {
        --_dialog-w: 100dvi;
        --_dialog-h: 100dvb;
        --_dialog-radius: 0;
        --_dialog-shadow: none;
        max-inline-size: 100dvi;
        max-block-size: 100dvb;
      }
    
      /* Below the sm band the viewport is a phone, and every dialog takes --ui-dialog-mobile-size
         over its preset: layout-bleed by default, so there is no page to see behind it. A style
         query reads the hook on the dialog's parent, never on the dialog itself: set it on :root
         for the site, or on one dialog's parent for that dialog alone. A viewport query, not a
         container one, because a top-layer dialog is sized by the viewport. Style queries are
         Firefox 151+; an older engine keeps the preset. A drawer (drawer.css) is a bottom sheet
         here instead, so every rule steps aside for it. */
      @media (width < 40rem) and (not (hover: hover)) {
        @container style(--ui-dialog-mobile-size: layout-bleed) {
          /* Not :where(): the viewport decides the height here, over a consumer's own cap
             on the same element (command's list max-block-size loads later at equal
             specificity). Utilities still win through the layer order. */
          [data-ui~="dialog"]:where(:not([data-ui~="drawer"])) [data-dialog-slot~="content"] {
            place-content: start stretch;
            block-size: 100%;
            padding-block-end: env(safe-area-inset-bottom, 0px);
          }
    
          [data-ui~="dialog"]:where(:not([data-ui~="drawer"])) [data-dialog-slot~="body"] {
            block-size: 100%;
            max-block-size: 100%;
            margin-block-end: auto;
          }
    
          :where([data-ui~="dialog"]:not([data-ui~="drawer"])) {
            --ui-dialog-border-color: transparent;
    
            --_dialog-w: 100dvi;
            --_dialog-h: 100dvb;
            --_dialog-radius: 0;
    
            margin: 0;
            max-inline-size: 100dvi;
            max-block-size: 100dvb;
            overflow: scroll;
            overscroll-behavior: contain;
            container: none;
          }
    
          :where(dialog:not([data-ui~="drawer"]))::backdrop {
            inline-size: 100dvi;
            block-size: 100dvb;
            inset: 0;
            opacity: 0;
            overscroll-behavior: contain;
            overflow: clip;
          }
        }
    
        @container style(--ui-dialog-mobile-size: layout-full) {
          :where([data-ui~="dialog"]:not([data-ui~="drawer"])) {
            --_dialog-w: calc(100dvi - var(--gutters) * 2);
          }
        }
      }
    }

    With form

    New project

    Add a project to your workspace. You can change these settings later.

    Contact
    We'll only use this to send receipts. Please enter a valid email address.
    Billing
    <button data-ui="button" type="button" command="show-modal" commandfor="form-dialog-1">
      New project
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
        <rect width="256" height="256" fill="none" />
        <line
          x1="40"
          y1="128"
          x2="216"
          y2="128"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
        <line
          x1="128"
          y1="40"
          x2="128"
          y2="216"
          fill="none"
          stroke="currentColor"
          stroke-linecap="round"
          stroke-linejoin="round"
          stroke-width="16"
        />
      </svg>
    </button>
    <dialog id="form-dialog-1" data-ui="dialog" closedby="any" data-dialog-size="sm">
      <div data-dialog-slot="content">
        <header data-dialog-slot="header">
          <h2
            style="
              --font-size: var(--font-size-lg);
              --font-weight: strong;
              --font-family: var(--font-family-heading);
            "
          >
            New project
          </h2>
          <p style="--text: var(--color-muted-foreground)">
            Add a project to your workspace. You can change these settings later.
          </p>
        </header>
        <form
          id="f-new-project-1"
          style="
            --display: flex-col;
            --gap: 6;
          "
          data-dialog-slot="body"
          method="dialog"
        >
          <fieldset data-ui="field-group">
            <legend style="--sr: only">Contact</legend>
            <div
              style="
                --display: grid;
                --grid-cols: 2;
                --gap: 4;
              "
            >
              <div data-ui="field">
                <label data-field-slot="label" for="fd-name">Name</label>
                <input
                  data-ui="input"
                  id="fd-name"
                  name="name"
                  type="text"
                  inputmode="text"
                  placeholder="Ada Lovelace"
                  required
                />
              </div>
              <div data-ui="field">
                <label data-field-slot="label" for="fd-email">Email</label>
                <input
                  data-ui="input"
                  id="fd-email"
                  name="email"
                  type="email"
                  inputmode="email"
                  required
                  placeholder="you@example.com"
                  autocomplete="email"
                  aria-describedby="fd-email-hint"
                />
                <div data-field-slot="description">
                  <span data-field-slot="hint" id="fd-email-hint"
                    >We'll only use this to send receipts.</span
                  >
                  <span data-field-slot="error" role="alert">Please enter a valid email address.</span>
                </div>
              </div>
              <label data-ui="field" style="--col-span: 2">
                <span data-field-slot="label">Repository</span>
                <div data-ui="input-group">
                  <input
                    data-ui="input"
                    type="search"
                    name="repo"
                    id="fd-repo"
                    inputmode="search"
                    placeholder="Search repositories…"
                  />
                  <span data-input-group-slot="addon">
                    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
                      <rect width="256" height="256" fill="none" />
                      <circle
                        cx="112"
                        cy="112"
                        r="80"
                        fill="none"
                        stroke="currentColor"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        stroke-width="16"
                      />
                      <line
                        x1="168.57"
                        y1="168.57"
                        x2="224"
                        y2="224"
                        fill="none"
                        stroke="currentColor"
                        stroke-linecap="round"
                        stroke-linejoin="round"
                        stroke-width="16"
                      />
                    </svg>
                  </span>
                </div>
              </label>
            </div>
          </fieldset>
    
          <fieldset data-ui="field-group">
            <div data-ui="field">
              <label data-field-slot="label" for="fd-message">Description</label>
              <textarea
                data-ui="textarea"
                id="fd-message"
                name="description"
                inputmode="text"
                placeholder="What is this project for?"
              ></textarea>
            </div>
          </fieldset>
    
          <fieldset data-ui="radio-group">
            <legend>Billing</legend>
            <label data-ui="field" data-field-orientation="horizontal">
              <input data-ui="radio" type="radio" name="billing" value="monthly" />
              <span data-field-slot="label">Monthly billing</span>
            </label>
            <label data-ui="field" data-field-orientation="horizontal">
              <input data-ui="radio" type="radio" name="billing" value="annual" checked />
              <span data-field-slot="label">Annual billing</span>
            </label>
          </fieldset>
    
          <label data-ui="field" data-field-orientation="horizontal">
            <input type="checkbox" name="terms" required />
            <span data-field-slot="label">Accept terms &amp; conditions</span>
          </label>
        </form>
        <footer data-dialog-slot="footer">
          <button
            data-ui="button"
            type="button"
            value="cancel"
            commandfor="form-dialog-1"
            command="close"
          >
            Cancel
          </button>
          <button
            data-ui="button"
            data-button-variant="primary"
            type="submit"
            form="f-new-project-1"
            value="save"
          >
            Create project
          </button>
        </footer>
        <button
          data-ui="button"
          data-dialog-slot="close"
          data-button-size="icon"
          data-button-variant="ghost"
          type="button"
          commandfor="form-dialog-1"
          command="close"
          aria-label="Close dialog"
        >
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
            <rect width="256" height="256" fill="none" />
            <line
              x1="200"
              y1="56"
              x2="56"
              y2="200"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
              stroke-width="16"
            />
            <line
              x1="200"
              y1="200"
              x2="56"
              y2="56"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
              stroke-width="16"
            />
          </svg>
        </button>
      </div>
    </dialog>
    /**
     * dialog.css — Dialog ([data-ui~="dialog"] on native <dialog>; slots
     *             data-dialog-slot="content | header | body | footer | close")
     *
     * @layer      variables, reset, components
     * @requires   _layers.css, _variables.css, _properties.css (--_*-resolved)
     * @uses       <dialog>, ::backdrop — native modal + backdrop
     * @uses       :root:has(dialog:modal) — overflow: hidden + scrollbar-gutter: stable while a modal
     *             is open (WebKit ignores overscroll-behavior on boxes that do not overflow)
     * @uses       @starting-style + allow-discrete — open/close opacity, transform, overlay
     * @uses       anchor-name, container-type — layout hooks for sized variants
     * @uses       corner-shape — superellipse corners; unsupported browsers keep plain
     *             rounded corners
     * @tokens     --ui-dialog-* (@layer variables; --ui-dialog-h defaults to a keyword, so the hook
     *             is read raw and takes a length or keyword; a --h utility or tier takes a scale
     *             number or a length; a keyword tier needs a base --h, or it renders as auto)
     * @presets    data-dialog-size="sm | md | lg | xl | 2xl | full | bleed" (the layout bands; sm when absent)
     * @uses       @media (width < 40rem) and (not (hover: hover)) + @container style(--ui-dialog-mobile-size)
     *             — below the sm band on a touch screen every dialog takes the hook's size (layout-bleed
     *             by default) over its preset; a narrow window with a mouse keeps the preset; style
     *             queries are Firefox 151+, Chrome 111+, Safari 18+, an older engine keeps the preset
     * @uses       env(safe-area-inset-bottom) — the full-height content slot clears the home indicator
     * @uses       translate, scale — in the transition list for consumers that move a dialog with
     *             them (drawer.js drags with an inline translate and releases into these
     *             transitions; a drawer behind another is scaled back)
     * @consumedby alert-dialog.css, command.css, drawer.css, lightbox.css, mobile-menu.css
     */
    
    @layer variables {
      :root {
        --ui-dialog-backdrop-color: var(--color-shade-900);
        --ui-dialog-transition-duration: var(--default-transition-duration);
        --ui-dialog-transition-timing-function: var(--default-transition-timing-function);
        --ui-dialog-backdrop-transition-duration: calc(var(--ui-dialog-transition-duration) / 2);
        --ui-dialog-backdrop-transition-timing-function: var(--bezier-easing);
        --ui-dialog-backdrop-filter: none;
        --ui-dialog-shadow: var(--shadow-lg);
        --ui-dialog-border-width: 1px;
        --ui-dialog-border-style: solid;
        --ui-dialog-border-color: var(--color-border);
        /* the sm band, the default size */
        --ui-dialog-w: min(var(--layout-sm), 100% - var(--gutters) * 2);
        /* below the sm band, the size every dialog takes: layout-bleed (edge to edge, no page
           behind it), layout-full (inside the gutters), or none (its own preset) */
        --ui-dialog-mobile-size: layout-bleed;
    
        /* Reveal transitions/animations */
        --ui-dialog-opacity--start: 0;
        --ui-dialog-opacity--end: 1;
        --ui-dialog-scale--start: 0.98;
        --ui-dialog-scale--end: 1;
        --ui-dialog-translate--start: 0, 0, 0;
        --ui-dialog-translate--end: 0, 0, 0;
        --ui-dialog-transition-delay--start: 0ms;
        --ui-dialog-transition-delay--end: 0ms;
      }
    }
    
    @layer variables {
      :root {
        --ui-dialog-h: fit-content;
        --ui-dialog-bg: var(--color-card);
        --ui-dialog-text: var(--color-card-foreground);
        --ui-dialog-radius: var(--radius-lg);
        --ui-dialog-corner-shape: var(--radius-corner-shape);
      }
    }
    
    @layer reset {
      /* ===========================================================================
      DIALOG — native <dialog> open/close animation, sizing, backdrop fade
      - In the reset layer so the dialog component styling below wins.
      =========================================================================== */
    
      /* Spring-eased open/close */
      :where(dialog) {
        isolation: isolate;
        margin: auto;
        max-inline-size: calc(100% - var(--space-md));
        max-block-size: calc(100% - var(--space-md));
        border: var(--ui-dialog-border-width) var(--ui-dialog-border-style)
          var(--ui-dialog-border-color);
        contain: layout style;
        opacity: var(--ui-dialog-opacity--start);
        box-shadow: var(--ui-dialog-shadow);
        overscroll-behavior: contain;
        overflow: hidden;
        transform: translate3d(var(--ui-dialog-translate--start)) scale(var(--ui-dialog-scale--start));
        transition:
          opacity var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          transform var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          translate var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          scale var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          padding var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          block-size var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          inline-size var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function),
          overlay var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function)
            allow-discrete,
          display var(--ui-dialog-transition-duration) var(--ui-dialog-transition-timing-function)
            allow-discrete;
        transition-delay: var(--ui-dialog-transition-delay--start);
      }
    
      :where(dialog[open]) {
        transform: translate3d(var(--ui-dialog-translate--end)) scale(var(--ui-dialog-scale--end));
        opacity: var(--ui-dialog-opacity--end);
        transition-delay: var(--ui-dialog-transition-delay--end);
    
        @starting-style {
          transition-delay: var(--ui-dialog-transition-delay--start);
          transform: translate3d(var(--ui-dialog-translate--start)) scale(var(--ui-dialog-scale--start));
          opacity: var(--ui-dialog-opacity--start);
        }
      }
    
      /* Backdrop fades via a discrete transition. Twice the viewport tall: with the
         software keyboard up, iOS shows the page below the rect fixed boxes fill, and a
         fixed box past the viewport edge creates no scroll. */
      :where(dialog)::backdrop {
        position: fixed;
        inline-size: 100%;
        block-size: 100%;
        inset: 0;
        opacity: 0;
        overscroll-behavior: contain;
        overflow: clip;
        background-color: var(--ui-dialog-backdrop-color);
        backdrop-filter: var(--ui-dialog-backdrop-filter);
        transition: opacity var(--ui-dialog-backdrop-transition-duration)
          var(--ui-dialog-backdrop-transition-timing-function);
      }
    
      :where(dialog[open])::backdrop {
        opacity: 1;
    
        @starting-style {
          opacity: 0;
        }
      }
    
      /* Chromium and Firefox contain page scroll through overscroll-behavior above; WebKit
         ignores it on a box that does not overflow (the backdrop, a short dialog), so the root
         locks while a modal is open. The gutter stays the width of the scrollbar it replaces,
         so neither the page nor the centred dialog shifts on open or on close; the scroll
         position survives. At rest no gutter is reserved. */
      :root:has(dialog:modal) {
        overflow: hidden;
        scrollbar-gutter: stable;
      }
    }
    
    /* Size privates: written by data-dialog-size, non-inheriting. */
    @property --_dialog-w {
      syntax: "*";
      inherits: false;
    }
    
    @property --_dialog-h-typed {
      syntax: "*";
      inherits: false;
    }
    @property --_dialog-h {
      syntax: "*";
      inherits: false;
    }
    
    @property --_dialog-radius {
      syntax: "*";
      inherits: false;
    }
    
    @property --_dialog-shadow {
      syntax: "*";
      inherits: false;
    }
    
    @layer ui.components {
      :where([data-ui~="dialog"]) {
        /* Set the hook on the element (not :root) so a later consumer (alert-dialog)
           or a subtree hook still wins; --_dialog-shadow is written only by the
           bleed preset. */
        --ui-dialog-shadow: var(--shadow-md);
    
        --_w-len: var(--_w-resolved, var(--_dialog-w, var(--ui-dialog-w)));
        --_w-num: var(--_w-resolved, var(--_dialog-w, var(--ui-dialog-w)));
        inline-size: calc(var(--_w-len) + var(--_w-num) * var(--spacing));
        /* The typed pair can't carry the hook's keyword. sign() adds nothing to the sum:
           its var() leaves --_dialog-h-typed unset without a --h, so the chain reaches the hook */
        --_h-len: var(--_h-resolved);
        --_h-num: var(--_h-resolved);
        --_dialog-h-typed: calc(
          var(--_h-len) + var(--_h-num) * var(--spacing) + 0px * sign(var(--_h-resolved))
        );
        block-size: var(--_dialog-h-typed, var(--_dialog-h, var(--ui-dialog-h)));
        background-color: var(--_bg-resolved, var(--ui-dialog-bg));
        color: var(--_text-resolved, var(--ui-dialog-text));
        box-shadow: var(--_shadow-resolved, var(--_dialog-shadow, var(--ui-dialog-shadow)));
        --_radius-len: var(--_radius-resolved, var(--_dialog-radius, var(--ui-dialog-radius)));
        --_radius-num: var(--_radius-resolved, var(--_dialog-radius, var(--ui-dialog-radius)));
        border-radius: calc(
          var(--_radius-len) + var(--_radius-num) * var(--spacing) * var(--radius-multiplier)
        );
        corner-shape: var(--_corner-shape-resolved, var(--ui-dialog-corner-shape));
    
        anchor-name: --ui-dialog-root;
        container-type: inline-size;
        container-name: dialog;
        font-size: var(--font-size-md);
        isolation: isolate;
        overflow: auto;
        overscroll-behavior: contain;
      }
    
      /* A one-row grid, so the content slot is capped by the dialog's height rather than
         sizing it (display went missing with the --ui-dialog-display token in 0.2). */
      :where([data-ui~="dialog"][open]) {
        display: grid;
        grid-template-rows: minmax(0, 1fr);
        min-block-size: 0;
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="close"] {
        position: absolute;
        inset-block-start: var(--space-xs);
        inset-inline-end: var(--space-xs);
        z-index: 50;
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="close"] > svg {
        inline-size: calc(var(--spacing) * 4);
        block-size: calc(var(--spacing) * 4);
        pointer-events: none;
        justify-content: center;
        align-items: center;
        display: flex;
        padding: 0;
      }
    
      /* Each slot owns a row, whatever the order and whichever are present: a body on its
         own still takes the flexible row, so it is the part that scrolls, never the dialog,
         and the close button keeps its corner. */
      :where([data-ui~="dialog"]) [data-dialog-slot~="content"] {
        display: grid;
        align-self: center;
        grid-template-rows: auto minmax(0, 1fr) auto;
        position: relative;
        min-block-size: 0;
        max-block-size: 100%;
        overscroll-behavior: contain;
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="header"] {
        grid-row: 1;
        display: flex;
        flex-direction: column;
        padding-inline: var(--space-sm);
        padding-block-start: var(--space-sm);
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="body"] {
        --_scroll-fade-gradient: linear-gradient(
          to bottom,
          transparent 0,
          #000 var(--_scroll-fade-start),
          #000 calc(100% - var(--_scroll-fade-end)),
          transparent 100%
        );
    
        grid-row: 2;
        display: grid;
        /* a full-height body keeps its rows at the top rather than spreading them */
        align-content: start;
        padding-inline: var(--space-sm);
        padding-block: var(--space-md);
        min-block-size: fit-content;
        max-block-size: 100%;
        overscroll-behavior: contain;
        overflow-y: auto;
    
        -webkit-mask-image: var(--ui-scroll-fade-mask, var(--_scroll-fade-gradient));
        mask-image: var(--ui-scroll-fade-mask, var(--_scroll-fade-gradient));
        -webkit-mask-composite: source-in;
        mask-composite: intersect;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
    
        @supports (animation-timeline: scroll()) {
          animation:
            ui-scroll-fade-reveal-start 1ms ease-in-out,
            ui-scroll-fade-reveal-end 1ms ease-in-out;
        }
    
        @supports not (animation-timeline: scroll()) {
          --_scroll-fade-start: var(--ui-scroll-fade-size);
          --_scroll-fade-end: var(--ui-scroll-fade-size);
        }
      }
    
      :where([data-ui~="dialog"]) [data-dialog-slot~="footer"] {
        grid-row: 3;
        block-size: fit-content;
        inset-block-end: 0;
        display: flex;
        justify-content: flex-end;
        align-self: end;
        flex-shrink: 0;
        gap: var(--space-xs);
        padding: var(--space-sm);
        border-block-start: 1px solid var(--color-border);
        background-color: var(--ui-dialog-bg);
      }
    
      /* Sizes follow the layout bands: sm … 2xl cap the width at the band (sm is the
         default), full spans the viewport inside the gutters, bleed fills it edge to edge. */
      :where([data-ui~="dialog"][data-dialog-size="sm"]) {
        --_dialog-w: min(var(--layout-sm), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="md"]) {
        --_dialog-w: min(var(--layout-md), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="lg"]) {
        --_dialog-w: min(var(--layout-lg), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="xl"]) {
        --_dialog-w: min(var(--layout-xl), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="2xl"]) {
        --_dialog-w: min(var(--layout-2xl), 100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="full"]) {
        --_dialog-w: calc(100% - var(--gutters) * 2);
      }
    
      :where([data-ui~="dialog"][data-dialog-size="bleed"]) {
        --_dialog-w: 100dvi;
        --_dialog-h: 100dvb;
        --_dialog-radius: 0;
        --_dialog-shadow: none;
        max-inline-size: 100dvi;
        max-block-size: 100dvb;
      }
    
      /* Below the sm band the viewport is a phone, and every dialog takes --ui-dialog-mobile-size
         over its preset: layout-bleed by default, so there is no page to see behind it. A style
         query reads the hook on the dialog's parent, never on the dialog itself: set it on :root
         for the site, or on one dialog's parent for that dialog alone. A viewport query, not a
         container one, because a top-layer dialog is sized by the viewport. Style queries are
         Firefox 151+; an older engine keeps the preset. A drawer (drawer.css) is a bottom sheet
         here instead, so every rule steps aside for it. */
      @media (width < 40rem) and (not (hover: hover)) {
        @container style(--ui-dialog-mobile-size: layout-bleed) {
          /* Not :where(): the viewport decides the height here, over a consumer's own cap
             on the same element (command's list max-block-size loads later at equal
             specificity). Utilities still win through the layer order. */
          [data-ui~="dialog"]:where(:not([data-ui~="drawer"])) [data-dialog-slot~="content"] {
            place-content: start stretch;
            block-size: 100%;
            padding-block-end: env(safe-area-inset-bottom, 0px);
          }
    
          [data-ui~="dialog"]:where(:not([data-ui~="drawer"])) [data-dialog-slot~="body"] {
            block-size: 100%;
            max-block-size: 100%;
            margin-block-end: auto;
          }
    
          :where([data-ui~="dialog"]:not([data-ui~="drawer"])) {
            --ui-dialog-border-color: transparent;
    
            --_dialog-w: 100dvi;
            --_dialog-h: 100dvb;
            --_dialog-radius: 0;
    
            margin: 0;
            max-inline-size: 100dvi;
            max-block-size: 100dvb;
            overflow: scroll;
            overscroll-behavior: contain;
            container: none;
          }
    
          :where(dialog:not([data-ui~="drawer"]))::backdrop {
            inline-size: 100dvi;
            block-size: 100dvb;
            inset: 0;
            opacity: 0;
            overscroll-behavior: contain;
            overflow: clip;
          }
        }
    
        @container style(--ui-dialog-mobile-size: layout-full) {
          :where([data-ui~="dialog"]:not([data-ui~="drawer"])) {
            --_dialog-w: calc(100dvi - var(--gutters) * 2);
          }
        }
      }
    }

    Sizes

    data-dialog-size follows the layout sizes. sm, md, lg, xl, and 2xl cap the width at that band (40, 48, 64, 80, and 96rem) and at the screen, inside the gutters. full spans the screen inside the gutters. bleed fills it edge to edge, with no radius or shadow, which is what the mobile menu and the lightbox use. With no size a dialog is sm.

    <dialog data-ui="dialog" data-dialog-size="lg" closedby="any">…</dialog>

    Below the sm band on a touch screen (a narrow desktop window keeps its preset), every dialog takes the size in --ui-dialog-mobile-size over its preset: layout-bleed by default, edge to edge and full height, with the content slot stretched to the bottom of the screen above the home indicator and only the body scrolling. layout-full keeps the gutters, and none keeps the dialog's own preset. The hook is read on the dialog's parent, so set it on :root for the site, or on one dialog's parent element for that dialog alone.

    :root {
      --ui-dialog-mobile-size: layout-full;
    }

    Light dismiss

    closedby="any" on the <dialog> lets a click on the backdrop close it, next to Esc. Chrome 134 and Firefox 141 do this natively. Safari 26 knows closedby but only its none and closerequest values, so any falls back to closerequest and the backdrop does nothing. The kit's dialog lifecycle script fills that gap: where any does not round-trip through the closedBy property, a press and release on the backdrop of a closedby="any" dialog calls requestClose(), which fires cancel as the native path does. Nothing in the markup changes, and the fallback stays idle where the browser handles it. A dialog that holds a form or a search still deserves a visible close button, for the people who find neither the backdrop nor Esc. closedby="none" (alert dialogs) and the default are left alone in both cases.

    Scrolling inside

    The content slot is a three-row grid, and each slot owns its row whatever the order it comes in: the header on top, the body in the flexible middle, the footer at the bottom. A tall body scrolls on its own, inside the dialog's height cap, so the header, the footer, and the close button hold still around it; that is true of a dialog with a body and nothing else too.

    Attributes

    dialog attributes
    AttributeKindValuesNotes
    data-ui="dialog"Identityfree valueIdentity token in data-ui.
    data-dialog-sizePreset2xl bleed full lg md sm xlPreset: a named bundle of values.
    data-dialog-slotSlotbody close content footer headerSlot: a part inside the primitive.

    Hooks

    Set a hook on :root, on a subtree, or inline on one element. A state hook (--…--hover) themes that state only; the primitive keeps its other states.

    dialog hooks
    HookDefaultState
    --ui-dialog-backdrop-colorvar(--color-shade-900)—
    --ui-dialog-backdrop-filternone—
    --ui-dialog-backdrop-transition-durationcalc(var(--ui-dialog-transition-duration) / 2)—
    --ui-dialog-backdrop-transition-timing-functionvar(--bezier-easing)—
    --ui-dialog-bgvar(--color-card)—
    --ui-dialog-border-colorvar(--color-border)—
    --ui-dialog-border-stylesolid—
    --ui-dialog-border-width1px—
    --ui-dialog-corner-shapevar(--radius-corner-shape)—
    --ui-dialog-hfit-content—
    --ui-dialog-mobile-sizelayout-bleed—
    --ui-dialog-opacity--end1end
    --ui-dialog-opacity--start0start
    --ui-dialog-radiusvar(--radius-lg)—
    --ui-dialog-scale--end1end
    --ui-dialog-scale--start0.98start
    --ui-dialog-shadowvar(--ui-alert-dialog-shadow)—
    --ui-dialog-textvar(--color-card-foreground)—
    --ui-dialog-transition-delay--end0msend
    --ui-dialog-transition-delay--start0msstart
    --ui-dialog-transition-durationvar(--default-transition-duration)—
    --ui-dialog-transition-timing-functionvar(--default-transition-timing-function)—
    --ui-dialog-translate--end0, 0, 0end
    --ui-dialog-translate--start0, 0, 0start
    --ui-dialog-wvar(--ui-alert-dialog-w)—

    API