Skip to content

CSS: modal

.instui-modal — A dialog surface (works on a native <dialog>); header/body/footer parts.

On a native <dialog>, showModal() puts the modal in the top layer and its ::backdrop becomes the mask, so no z-index is needed. An <img> alone in .body goes full-bleed.

Source: modal.css

Accessibility

Open the native <dialog> with showModal() for modal semantics and Esc-to-close, and name it with aria-labelledby pointing at the .header.

Usage

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/modal.css";

Demo

Examples

html
<dialog class="instui-modal -size-sm" id="modal-sm">
  <div class="header"><strong>Small</strong></div>
  <div class="body"><code>-size-sm</code> — a narrow modal.</div>
  <div class="footer">
    <button class="instui-button">Close</button>
  </div>
</dialog>

Structure

text
.instui-modal.-size-sm
  .header
    strong
  .body
    code
  .footer
    button (component)
flowchart TD n0[".instui-modal.-size-sm"]:::cssdoc-root n1(".header"):::cssdoc-part n2("strong"):::cssdoc-part n3(".body"):::cssdoc-part n4("code"):::cssdoc-part n5(".footer"):::cssdoc-part n6(["button"]):::cssdoc-component n1 --> n2 n0 --> n1 n3 --> n4 n0 --> n3 n5 --> n6 n0 --> n5 click n6 "/api/css/button.md" classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

Modifiers

ModifierDescription
.-blurBlur the backdrop behind the modal.
.-color-inverseOn-dark chrome (pairs with a media body).
.-density-compactTighter part padding.
.-overflow-fitConstrain to the viewport and scroll the body.
.-size-autoSized to content.
.-size-fullscreenEdge-to-edge.
.-size-largeA wide modal. Long-form alias of -size-lg.
.-size-lgA wide modal.
.-size-smA narrow modal.
.-size-smallA narrow modal. Long-form alias of -size-sm.

Parts

PartDescription
.bodyThe content region (a lone <img> goes full-bleed).
.footerThe actions row.
.headerThe title row.

Pseudo-elements

Pseudo-elementDescription
::backdropDims the page behind the dialog as its mask, and frosts it under -blur.

Tokens consumed

TokenTypeValue
--instui-component-mask-background-color<color>light-dark(rgba(255,255,255,0.75), rgba(28,34,43,0.75))LightDark
--instui-component-modal-auto-min-width<length>16em
--instui-component-modal-background-color<color>light-dark(#ffffff, #171B21)LightDark
--instui-component-modal-body-inverse-background-color<color>light-dark(#273540, #1C222B)LightDark
--instui-component-modal-body-padding<length>1.5rem
--instui-component-modal-body-padding-compact<length>0.75rem
--instui-component-modal-border-color<color>light-dark(#E8EAEC, #334450)LightDark
--instui-component-modal-border-radius<length>1rem
--instui-component-modal-border-width<length>0.0625rem
--instui-component-modal-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-modal-footer-background-color<color>light-dark(#ffffff, #171B21)LightDark
--instui-component-modal-footer-border-color<color>light-dark(#E8EAEC, #334450)LightDark
--instui-component-modal-footer-border-radius<length>1rem
--instui-component-modal-footer-border-width<length>0.0625rem
--instui-component-modal-footer-inverse-background-color<color>light-dark(#273540, #1C222B)LightDark
--instui-component-modal-footer-inverse-border-color<color>#334450
--instui-component-modal-footer-padding<length>1.5rem
--instui-component-modal-footer-padding-compact<length>0.75rem
--instui-component-modal-header-background-color<color>light-dark(#ffffff, #171B21)LightDark
--instui-component-modal-header-border-color<color>light-dark(#E8EAEC, #334450)LightDark
--instui-component-modal-header-border-width<length>0.0625rem
--instui-component-modal-header-inverse-background-color<color>light-dark(#273540, #1C222B)LightDark
--instui-component-modal-header-inverse-border-color<color>#334450
--instui-component-modal-header-padding<length>1.5rem
--instui-component-modal-header-padding-compact<length>0.75rem
--instui-component-modal-inverse-background-color<color>light-dark(#273540, #1C222B)LightDark
--instui-component-modal-inverse-border-color<color>#334450
--instui-component-modal-inverse-text-color<color>#ffffff
--instui-component-modal-large-max-width<length>62em
--instui-component-modal-medium-max-width<length>48em
--instui-component-modal-small-max-width<length>30em
--instui-component-modal-text-color<color>light-dark(#273540, #F2F4F5)LightDark
--instui-elevation-topmost[ inset? && <length>{2,4} && <color>? ]# | none
--instui-spacing-space-xl<length>1.5rem

Browser support

  • Styles a native <dialog> and its ::backdrop; the top-layer rendering and backdrop styling need a browser that supports the dialog element.

Subcomponents

  • tray — A tray is the same dismissible overlay pattern, anchored to a screen edge.