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

Reduce motion:Off
Inspect

Component walkthrough

Try it alongside the tutorial

Float the video, then complete these fields without losing your place.

Installation

Usage

Props

PropertyTypeDefaultDescription
childrenReactNoderequiredMedia or reference content that remains mounted while the viewer moves.
ariaLabelstring"Floating media viewer"Accessible name announced for the floating viewer.
aspectRatiostring"16 / 9"CSS aspect-ratio value used by both viewer states.
floatingWidthnumber320Width of the floating surface in pixels.
viewportPaddingnumber16Gap between the floating surface and viewport edges in pixels.
defaultCornerFloatingViewerCorner"bottom-right"Corner used when the viewer first detaches.
floatOnExitbooleantrueAutomatically detach when the inline viewer leaves the viewport.
showFloatControlbooleantrueShows the built-in Float button while the viewer is inline.
onFloatingChange(floating: boolean) => voidundefinedCalled whenever the viewer enters or leaves its floating state.
surfaceClassNamestringundefinedAdditional 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.