@gfazioli/mantine-scene
A composable decorative background component for React applications built with Mantine. Layer gradients, glow blobs, dot grids, mesh gradients, and noise textures to create rich atmospheric backgrounds.
Installation
After installation import package styles at the root of your application:
You can import styles within a layer @layer mantine-scene
by importing @gfazioli/mantine-scene/styles.layer.css
file.
Usage
Scene is a decorative background container that
composes multiple visual layers: gradients, glow
blobs, dot grids, mesh gradients, noise textures,
star fields, shooting stars, snow, and auroras.
Place it behind your content to create rich,
atmospheric backgrounds.
The root element has aria-hidden="true" since
it is purely decorative.
Fullscreen
Set fullscreen to cover the entire viewport with
position: fixed. The scene sits behind all content
at z-index: 0 by default (configurable via the
zIndex prop).
See the fullscreen demo page →
Reduced Motion
Scene respects prefers-reduced-motion by default.
Use the reducedMotion prop to control behavior:
'auto'(default) — disables animations when the user has enabled reduced motion in their OS settings'always'— always disables all animations'never'— keeps animations regardless of user preference
Interactive
Set interactive on the root Scene to enable mouse
tracking. Sub-components that support it will react
to the cursor position automatically:
Scene.StarWarp— focal point follows the mouseScene.Glow— blob position follows the mouseScene.Gradient— radial/conic gradient center follows the mouse
When the mouse leaves the scene, components fall back to their default position props.
onMousePosition callback
When interactive is enabled, pass onMousePosition
to receive every smoothed cursor update. The callback
receives { x, y } as percentages (0–100) relative
to the scene container — useful for coordinating
external UI elements with the scene's tracking.
x: —y: —Lazy mode
Set lazy on the root Scene to pause all child
animations and the internal mouse-tracking
requestAnimationFrame loop when the scene leaves
the viewport. Animations resume automatically when
the scene re-enters.
This uses IntersectionObserver under the hood and
is opt-in (default false) to preserve backwards
compatibility. Tune the visibility threshold via
lazyThreshold (0–1).
When paused, the root receives a data-paused
attribute and a CSS rule sets
animation-play-state: paused on every child
element — no React re-render or remount required.
Scroll the page — when this scene leaves the viewport, all child animations and the mouse-tracking rAF loop pause. They resume automatically when it re-enters.
Responsive Props
Some props accept Mantine's StyleProp<T> —
either a static value or a breakpoint object
(e.g. { base: 30, md: 100 }). CSS-derivable values
(sizes, spacings) are emitted as scoped CSS variables
with @media queries via Mantine's InlineStyles,
so they update with zero React re-renders on
viewport changes — the same pattern used by Mantine
core's SimpleGrid.
Supported responsive props:
Scene.Glow—size,blur(CSS-driven, no re-render)Scene.DotGrid—spacing(CSS-driven, no re-render)Scene.StarField—count(resolved in JS — particles re-seed at breakpoints)Scene.StarWarp—count(resolved in JS)Scene.Snow—count(resolved in JS)Scene.Rain—count(resolved in JS)Scene.Confetti—count(resolved in JS)
Plain number values continue to work as before —
responsive objects are entirely opt-in. The legacy
ResponsiveValue<T> type re-export remains for
backwards compatibility but is now an alias for
StyleProp<T> and is marked as deprecated.
Gradient
Scene.Gradient supports three types: radial
(default), linear, and conic. Use from and
to with Mantine theme colors, or pass raw CSS
color stops via colors.
Set animate to enable rotate (hue-rotate) or
pulse (opacity oscillation) animations.
Glow
Scene.Glow renders animated floating blobs.
Each blob can be positioned, sized, and animated
independently. Disable animation with
animate={false}.
Choose between animation types: float (default),
pulse (scale oscillation), and breathe (opacity
oscillation). Use delay to stagger multiple blobs.
DotGrid
Scene.DotGrid creates a repeating dot pattern.
Enable stagger for a honeycomb-like layout.
Use fade to mask the edges (radial, top,
bottom, or edges).
Mesh
Scene.Mesh overlays multiple radial gradients
to simulate a mesh gradient effect. Define color
stops with position and spread.
Set animate to enable a hue-rotate shift. Use
blend to change the CSS mix-blend-mode.
Noise
Scene.Noise adds a film grain texture via an
inline SVG filter. Control the noise with seed,
type, and octaves. Use tint with a Mantine
theme color to overlay a color tint.
StarField
Scene.StarField renders a CSS-only star field
using box-shadow on a single element per layer.
Stars are positioned deterministically via a PRNG
seeded with the seed prop.
Enable twinkle for a staggered opacity animation
across three layers.
StarWarp
Scene.StarWarp creates a classic hyperspace / warp
speed effect where stars radiate from a configurable
focal point. Stars scale up as they move outward,
simulating depth and perspective.
Use direction to choose between flying away (out)
or approaching (in). Move the focal point with
focalX / focalY to shift the vanishing point.
Enable trail for elongated streaks.
ShootingStar
Scene.ShootingStar creates streaks of light that
traverse the scene at a configurable angle. Each
trail has a gradient from transparent to the chosen
color.
Control count (number of lanes), trailLength,
speed, and minInterval/maxInterval between
appearances.
Snow
Scene.Snow renders falling snowflakes with
horizontal drift. Each flake has a randomized size,
speed, and position (deterministic via seed).
Use wind (-1 to 1) to bias the drift direction
and speed as a multiplier on fall duration.
Rain
Scene.Rain renders falling raindrops as angled
streaks. Customize count, color, streak angle
(degrees), thickness, and speed. Min/max
streak length are randomized per drop.
Enable splash to render expanding splash rings at
the bottom edge. Tune the effect with splashCount,
splashSize (base diameter), splashOpacity, and
splashThickness (ring width). splashColor
overrides the default (which mirrors color).
For a thunderstorm effect, combine Scene.Rain with
a bright Scene.Glow to simulate a lightning flash.
Confetti
Scene.Confetti renders multi-colored falling
confetti pieces with rotation and horizontal flutter.
Each piece picks one shape from shapes
('rectangle', 'circle', or 'triangle') and one
color from the colors palette (Mantine theme
colors).
Tune count, duration, flutter (sway range in
px), and the size range with minSize/maxSize.
Origin: top vs bottom
Set origin="bottom" to flip the animation into a
"confetti cannon" — pieces shoot upward in a
parabolic arc, peak at rise pixels above the bottom
edge, then fall back down. Pair it with burst for a
celebratory one-shot blast triggered from a button.
Continuous mode
By default Scene.Confetti loops continuously,
emitting pieces in an infinite stream. Use the
configurator below to tune count, sizes, flutter,
and timing.
Burst mode with onComplete
Set burst to run a single one-shot animation
instead of looping. Combine it with a React key to
retrigger the burst on demand — the onComplete
callback fires once the last piece has settled.
Triggered: 0
Completed: 0
Aurora
Scene.Aurora creates shimmering aurora borealis
bands. Each band is a blurred, colored rectangle
with a wave animation.
Customize colors (Mantine theme colors), bands
count, position (top/center/bottom), blur,
and opacity.
Waves
Scene.Waves renders a stack of parallax SVG wave
layers that pan horizontally for a soothing,
ocean-like background. Each layer's path is generated
deterministically from the seed and tiles seamlessly
under a translateX(-50%) CSS animation — no
requestAnimationFrame, no canvas, no React
re-renders during the animation.
Pass a single Mantine theme color to derive shades
across layers automatically (back layers use lighter
shades, front layers darker), or an explicit array
to map a specific color per layer. Use position
('top' / 'bottom') to anchor the waves to either
edge.
Use direction ('left' / 'right') to flip the
horizontal pan, and parallax to control the speed
differential between foreground and background
layers:
parallax={0}flattens parallax — all layers move at the same speedparallax={1}(default) is the standard depth effectparallax={2}exaggerates the differential- Negative values invert the parallax (background layers faster than foreground), creating a dreamy reverse-depth feel
Combined
All sub-components can be composed freely. Layer order follows DOM order.