Overlay
The floating card every anchored or modal panel is built on.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
The floating card every anchored or modal panel is built on.
Import
import { OverlaySurface, OverlayScrim } from "@ir/ui";Watch out
- In Figma neither variant is attached to an effect style — both carry raw effects. The values are byte-identical to
shadow/mdandshadow/lg(same radii, offsets and alphas; only the two drop shadows are listed in the opposite order), so it looks right today and would silently stop matching if the shadow scale ever moved. Bound to the tokens here. Raised for the file.
Variants
| Axis | Options | Default |
|---|---|---|
density | compact · comfortable | compact |
Do and don't
Change the surface, and let all of them move together.
Don't — Restyle the panel inside Popover, Dropdown menu or Dialog.
The file says so in as many words. Four near-identical floating cards is how a system stops looking like one system.
Compact for rows, comfortable for prose.
Don't — Use comfortable for a list of menu rows.
Compact's 4px padding lets a row's own padding reach the edge; comfortable's 16 gives paragraphs room.
Put overlaySurfaceVariants on the Content element itself.
Don't — Wrap Radix's Content in a styled div.
Radix positions and animates that node. A wrapper leaves the shadow behind when it moves and breaks the exit animation.
Trap focus and label the panel; the scrim is decoration.
Don't — Rely on dimming to say something is modal.
A screen reader never sees the dimming. What makes a dialog modal is that nothing behind it can be reached.
Save the scrim for dialogs and drawers.
Don't — Dim the page behind a popover or a menu.
A scrim says "finish this first". A menu you can dismiss by looking away is not making that demand.
Accessibility
- The scrim is aria-hidden. It is a dimming surface, not a control, and the dialog or drawer above it owns the modal semantics.
- Overlay supplies no roles of its own. Everything built on it — Dialog, Drawer — brings its own Radix primitive and its own accessible name.
Where it is drawn
Figma — structure from figma, measurements from figma.