Overlay
Content layered over media on hover, focus, or persistently.
Content layered over media on hover, focus, or persistently.
The examples use photographs from Unsplash by ConfinedRiley, Tim G, and Sebastian Schuster.
Anatomy
Section titled “Anatomy”Overlay keeps the base surface and its layered content in one bounded stacking context.
<Overlay position="bottom" showOn="hover" content={<span>Workspace overview</span>}> <img src="/workspace.png" alt="Workspace dashboard" /></Overlay>Import
Section titled “Import”import { Overlay } from "@zentara-co/zenos-ui";Overlay layers short content or actions over a bounded surface. It does not create a modal, portal, focus trap, or page backdrop.
Visibility
Section titled “Visibility”hover also reveals when focus enters the overlay so keyboard users can reach its content. Use focus when pointer hover should not expose the layer, and always for persistent captions or controls. hover-or-focus remains a backwards-compatible alias for hover.
Position
Section titled “Position”position="fill" uses a uniform layer. top and bottom use directional fades that remain strongest beside the content and reveal more of the media toward the opposite edge. Use align="start" with top content and align="end" with bottom content.
Dark and light scrims keep their visual polarity in both color schemes, so their foreground color remains predictable. Nested content should inherit the scrim color; when using a component with its own color prop, explicitly choose a color that contrasts with the selected scrim. Use scrim={false} only when custom content supplies its own readable surface.
Controlled visibility
Section titled “Controlled visibility”Supply open when another control owns visibility and update it from onOpenChange. A closed controlled overlay becomes inert so hidden actions cannot receive focus. Touching a non-interactive area requests the next controlled state through onOpenChange.
Custom styling
Section titled “Custom styling”Use className for the bounded root and contentClassName for the positioned layer. This keeps layout customization separate from the media and lets a custom panel replace the built-in scrim without rebuilding visibility behavior. Pair semantic surface, border, and foreground tokens so the treatment maintains contrast in both light and dark modes; nested components with their own color styles should use the same foreground family.
Overlay or another component
Section titled “Overlay or another component”Use Overlay for content that remains physically attached to a media or card surface. Use Popover for anchored floating content, Dialog for modal tasks, and Lightbox for fullscreen media viewing.
API
| Prop | Type | Default | Description |
|---|---|---|---|
content | ReactNode | — | Content shown over children. |
contentClassName | string | — | Adds classes to the positioned content layer. |
showOn | OverlayShowOn | always | Visibility interaction; hover also reveals on focus for keyboard access. |
scrim | dark | light | false | dark | Theme-independent dark, light, or consumer-styled backdrop treatment. |
position | fill | top | bottom | fill | Uniform fill or directional top/bottom fade placement. |
align | start | center | end | end | Vertical content alignment within the positioned layer. |
open | boolean | — | Controlled visibility override. |
defaultOpen | boolean | false | Initial touch visibility for uncontrolled usage. |
onOpenChange | (open: boolean) => void | — | Runs when touch interaction requests a visibility change. |
native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |
Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props,
including className, style, aria-*, and data-*.
Accessibility
Section titled “Accessibility”Overlay preserves the semantics of its children and content. Hover-revealed content also appears on focus-within, and controlled hidden content is inert. Keep essential information available without hover, provide meaningful alternative text for media, and maintain sufficient contrast for custom scrims. Touch taps toggle revealable overlays unless the tap targets an interactive element.