Float layer
MotionAn entrance, scroll depth and gentle idle movement for a real component or a group of elements.
Try it
Add to your project
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/float-layer.jsonThe command includes the component’s shared dependencies. Your project keeps editable source files.
Include the complete example
This example also composes card, shape, typography. Install its parts together:
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/float-layer.json https://luv-jeri.github.io/cojeev-ui/r/card.json https://luv-jeri.github.io/cojeev-ui/r/shape.json https://luv-jeri.github.io/cojeev-ui/r/typography.jsonUsing float layer
Set depth and drift in pixels. Use depth={0} drift={0} for a stationary foreground after its entrance; reserve idle drift and parallax for background layers.
Tune revealDuration (0.2–2 seconds), revealDistance (0–80 pixels) and delay. Set replay to reveal again whenever the layer re-enters the viewport.
The default wrapper keeps transforms separate. asChild preserves the child element; use the wrapper when that child owns an inline CSS translate.
API
Compose the exported parts below. The prop types are read from the React source during the registry build.
Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.
FloatLayerProps
| Prop | Type | Required |
|---|---|---|
depthTotal native-scroll displacement in px. Negative values reverse the plane. | number | No |
delayEntrance delay in seconds; bounded to one second. | number | No |
driftGentle idle excursion in px. Set zero for scroll-only depth. | number | No |
replayRepeat the entrance when the layer leaves and re-enters the viewport. | boolean | No |
revealDurationEntrance duration in seconds, clamped to 0.2–2. | number | No |
revealDistanceInitial vertical entrance offset in px, clamped to 0–80. | number | No |
asChild | boolean | No |
ref | React.Ref<HTMLElement> | No |
data-slot | string | No |
Accessibility
Server-rendered content stays readable before hydration.
Reduced motion and Motion Off leave content visible and still; offscreen and hidden-page work pauses.
States and appearance
For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.
Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.