Showcases and examples
3 documented examples
Preview loads on approachPreview loads on approach
Exact source · overlay-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {Overlay} from '@astryxdesign/core/Overlay';
import {AspectRatio} from '@astryxdesign/core/AspectRatio';
import {Button} from '@astryxdesign/core/Button';
import {VStack} from '@astryxdesign/core/Layout';
import {Text} from '@astryxdesign/core/Text';
export default function OverlayShowcase() {
return (
<Overlay
align="center"
content={
<VStack gap={2} style={{textAlign: 'center'}}>
<Text type="supporting" weight="bold" color="inherit">
Design system foundations
</Text>
<Button label="Open gallery" variant="secondary" size="sm" />
</VStack>
}>
<AspectRatio
ratio={16 / 9}
style={{
width: 520,
maxWidth: '100%',
borderRadius: 16,
overflow: 'clip',
}}>
<img
src="/template-assets/light-scene-horizontal-1.png"
alt="Abstract landscape"
style={{width: '100%', height: '100%', objectFit: 'cover'}}
/>
</AspectRatio>
</Overlay>
);
}
Usage
Overlay layers action or supporting content over media, cards, video, or other bounded surfaces with an optional scrim and reveal behavior.
- Use overlays for short, contextual actions or labels that belong directly to the underlying media or surface.
- Keep overlay content compact so it remains legible over the scrim and does not obscure important visual information.
- Do not use Overlay for floating content anchored outside the surface. Use Popover, Tooltip, or Dialog for those patterns.
Typed props
| Prop | Type and behavior |
|---|
content | ReactNode · requiredContent rendered inside the overlay scrim. |
|---|
children | ReactNodeBase content such as an image, video, card, or media surface that the overlay sits on top of. |
|---|
showOn | 'hover' | 'always' | 'focus' | 'hover-or-focus' · default 'always'Visibility trigger. Hover mode also reveals on focus for keyboard accessibility; hover-or-focus is an alias for hover. |
|---|
isOpen | booleanControlled visibility override. When set, this takes precedence over showOn and touch toggle behavior. |
|---|
scrim | 'dark' | 'light' | false · default 'dark'Scrim background mode. Set to false to render overlay content without a scrim background. |
|---|
position | 'fill' | 'bottom' | 'top' · default 'fill'Where the scrim appears within the base surface. |
|---|
align | 'start' | 'center' | 'end' · default 'end'Alignment of the overlay content within the scrim. |
|---|
xstyle | StyleXStylesStyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value, not an inline style object like style={{}}. |
|---|
className | stringCSS class name(s) appended to the root element. Prefer xstyle for styling when possible. |
|---|
style | React.CSSPropertiesInline styles applied to the root element. Prefer xstyle for design-system styling. |
|---|
ref | Ref<HTMLDivElement>Ref forwarded to the overlay root element. |
|---|
Anatomy
Base content · optionalThe media, card, or bounded surface that the overlay sits on top of.
Scrim · optionalOptional dark or light overlay background that improves content contrast.
Overlay content · requiredActions, labels, or supporting content rendered above the base surface.
Theming
Targets
astryx-overlay
astryx-overlay-scrimVisual props: position