Skip to content
Cojeev UI

Float layer

Motion

An entrance, scroll depth and gentle idle movement for a real component or a group of elements.

React · copy into your project · light and dark themes

Try it

Loading preview…

Take it with you

Copy the example, API and usage notes for your editor or AI assistant.

Add to your project

Terminal
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/float-layer.json

The 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:

Terminal
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.json

Using 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

PropTypeRequired
depth

Total native-scroll displacement in px. Negative values reverse the plane.

numberNo
delay

Entrance delay in seconds; bounded to one second.

numberNo
drift

Gentle idle excursion in px. Set zero for scroll-only depth.

numberNo
replay

Repeat the entrance when the layer leaves and re-enters the viewport.

booleanNo
revealDuration

Entrance duration in seconds, clamped to 0.2–2.

numberNo
revealDistance

Initial vertical entrance offset in px, clamped to 0–80.

numberNo
asChildbooleanNo
refReact.Ref<HTMLElement>No
data-slotstringNo

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

entrancescrollidlereduced-motion

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.