Skip to content

Atmosphere

Float a card on a painted, grainy ground: a meadow, dunes, a copper glow or a dusk, each with a preset to match.

import { Atmosphere } from '@youj/motion/backgrounds'

Experimental: what this label means

Installation & usage

npm i @youj/motion

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

Use it for a launch page, a sign-up or a product shot: anywhere one card should be the hero on a ground with some weather to it. Give it the preset of the same name, and keep one per page.

It fills its nearest positioned ancestor and paints behind your content, so make the container relative and isolate.

import { meadow, YoujProvider } from '@youj/core'
import { Atmosphere } from '@youj/motion/backgrounds'

export function Launch() {
  return (
    <YoujProvider theme={meadow}>
      <section className="relative isolate grid min-h-dvh place-items-center p-6">
        <Atmosphere scene="meadow" />
        <YourCard />
      </section>
    </YoujProvider>
  )
}

Reference

Propsscene, colors, speed… (5)

Props

Atmosphere props
PropType
sceneAtmosphereScene
'meadow''sandstone''cinnabar''umber'

The ground: meadow (a panned meadow under sky), sandstone (lit dunes with a suede grain), cinnabar (a dark ground glowing into English red) or umber (a grainy dusk). Each pairs with the theme preset of its name.

default 'meadow'

'meadow'
colorsreadonly string[]

Five CSS colors in the scene's own order (meadow: sky, haze, grass, deep, glint; sandstone: light, mid, shadow, deep, rim; cinnabar: base, low, mid, glow, band; umber: sky, glow, middle, low, deepest), in place of its palette for both modes. Tokens follow the mode.

–
speednumber

Drift speed multiplier.

default 1

1
grainnumber

Film grain, 0–1. Default: the scene's own (stronger on cinnabar, finer on sandstone, which has its own suede).

–
classNamestring–
PerformanceOne fragment shader, at most 24 frames a second, paused off screen

Performance

Each scene is one WebGL2 fragment shader on a single full-screen triangle, at a device-pixel ratio capped at 1.5 (1 on a low-power device). It draws at most 24 frames a second, since its drift is slow, and pauses off screen and in a hidden tab. It survives a lost GL context and releases the context on unmount. Without WebGL2 it's a still CSS gradient in the same palette, with grain, chosen for the page's light or dark.

MotionDrift · reduced motion

Motion

Motion tokens
MomentTokens
Driftthe meadow slides along its streaks, the dunes and bands shift, the dusk glow wanders
no token

speed ÷ time scale

speed ÷ time scale
Graina fresh pattern each frame, like film
no token

at most 24 frames a second

at most 24 frames a second

Reduced motion

Draws one composed still frame with the grain halved, and stops. It redraws only when the size, the props or the theme change.

Reduced motion

Each scene draws one composed frame and holds it, with the grain halved and still. The composition and the palette stay the same, so the page looks as designed, only still. Switch on Reduced motion in any preview above to compare.

AccessibilityDecorative

Accessibility

It's decorative, so it's aria-hidden and ignores pointer events. Keep text on a card, not on the scene: the grounds vary in lightness across the frame, and only the card's surface is held to your theme's contrast.