Floating Viewer
Use Floating Viewer to keep reference media visible while someone works elsewhere on the page. It can detach automatically when its inline position leaves the viewport or through an explicit control.
Preview
Component walkthrough
Installation
Usage
Props
| Property | Type | Default | Description |
|---|---|---|---|
children | ReactNode | required | Media or reference content that remains mounted while the viewer moves. |
ariaLabel | string | "Floating media viewer" | Accessible name announced for the floating viewer. |
aspectRatio | string | "16 / 9" | CSS aspect-ratio value used by both viewer states. |
floatingWidth | number | 320 | Width of the floating surface in pixels. |
viewportPadding | number | 16 | Gap between the floating surface and viewport edges in pixels. |
defaultCorner | FloatingViewerCorner | "bottom-right" | Corner used when the viewer first detaches. |
floatOnExit | boolean | true | Automatically detach when the inline viewer leaves the viewport. |
showFloatControl | boolean | true | Shows the built-in Float button while the viewer is inline. |
onFloatingChange | (floating: boolean) => void | undefined | Called whenever the viewer enters or leaves its floating state. |
surfaceClassName | string | undefined | Additional CSS classes for the media surface. |
Accessibility
The floating surface is announced as a labeled region and every action is available without dragging. Restore scrolls the inline position into view, while Close suppresses automatic floating until the inline viewer becomes visible again.
Motion
The viewer uses a critically damped spring to preserve spatial continuity while snapping between corners. Reduced-motion preferences replace spatial movement with immediate state changes.
Styling
Use the component for one persistent media surface and let the consumer own the media controls, captions, and content. Avoid placing important page controls beneath the viewport corners where the floating surface can rest.
Was this component useful?
Your feedback helps us improve the documentation.