Components / More
OverlayFrame
A frame whose content fills it, with an overlay pinned at the bottom centre that stays put while the content scrolls under it: a "3 new" pill, a "jump to latest" button.
When to useLink to "When to use"
ScrollArea and VirtualList already hold their scroller in an OverlayFrame and take an overlay prop: use those. Reach for OverlayFrame directly only to put the same overlay over a scroller of your own (a canvas, a code view).
Use something else when the content should move aside for the control (put it below the content in a Stack), or when it floats next to a selection (FloatingToolbar).
UsageLink to "Usage"
import { OverlayFrame } from "@arshad-shah/cynosure";
<OverlayFrame overlay={unseen > 0 && <Button onClick={jump}>{`${unseen} new`}</Button>}>
<div style={{ overflow: "auto" }}>…</div>
</OverlayFrame>PropsLink to "Props"
| Prop | What it does | Type | Default |
|---|---|---|---|
overlay | Content pinned over the frame at the bottom centre that does not scroll with what it covers: a "3 new" pill, a "jump to latest" button. Nothing (null, undefined or false): no overlay. | ReactNode | |
children | What the overlay sits over: one element (a scroller) that fills the frame. | ReactNode | |
className | Added to the root element, for layout. | string | |
style | Layout only. Restyle through --cy-overlay-frame-* tokens. | CSSProperties | |
data-testid | Set on the root element, for tests. | string |
Generated from the type definitions in @arshad-shah/cynosure 0.5.0.
Behaviour and accessibilityLink to "Behaviour and accessibility"
- The content and the overlay share one grid cell: the content fills the frame and the overlay sits over its bottom centre, a little above the edge. Scrolling the content leaves it where it is.
- The overlay is outside the content, so it is not part of a listbox or a named region it covers; give it a control with its own name.
- It stacks above content raised with a z-index up to 2 (a sticky heading), so presses reach it.
null,undefinedandfalserender no overlay. The frame itself stays, so the content is never remounted and keeps its scroll position.
ThemingLink to "Theming"
Tokens: --cy-overlay-frame-offset (space between the bottom edge and the overlay, default --cy-space-4) and --cy-overlay-frame-layer (the overlay's stacking order, default 3). Set them on the frame (a ScrollArea's root is one) or on any element around it.
RelatedLink to "Related"
ScrollArea and VirtualList render it for their overlay.
These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.