Adventureland Registry

Background Component

A polymorphic background renderer supporting dithering, mesh-gradient, WebGL pixel art, dotted-grid pattern, or no background — all theme-aware via next-themes.

BackgroundComponent is a single component that switches between five background modes via its type prop. Each mode accepts its own configuration props for colours and animation, plus shared colors / animation config objects for unified overrides.

The component listens to next-themes to provide sensible dark/light defaults automatically.

SSR note — This component uses WebGL/canvas. Load it with dynamic(() => import(...), { ssr: false }) where the WebGL type is used.

Installation

npx shadcn@latest add @adv/background-component

Usage

import dynamic from 'next/dynamic';

const BackgroundComponent = dynamic(
  () => import('@/components/BackgroundComponent').then(m => m.BackgroundComponent),
  { ssr: false }
);

// Dithering shader (default theme-aware colours)
<div className="relative h-screen">
  <BackgroundComponent type="dithering" />
</div>

// Mesh gradient with custom colours
<BackgroundComponent
  type="mesh-gradient"
  colors={['#e7fa7a', '#9a381d', '#f79850', '#d4704e']}
  speed={0.5}
/>

// Dotted grid pattern
<BackgroundComponent type="pattern" gridPattern="dark-white" />

Example

Props

All variants share className, style, and children.

type="dithering"

PropTypeDefaultDescription
colorBackstringtheme-awareBackground colour.
colorFrontstringtheme-awareForeground/dither colour.
shape"warp" | "circle" | "square" | "triangle""warp"Dither shape.
ditherType"4x4" | "8x8" | "16x16""8x8"Dither matrix size.
pxSizenumber1.8Pixel size of dither pattern.
speednumber0.06Animation speed.
scalenumber2.7Pattern scale.
rotationnumber100Rotation angle.
offsetX / offsetYnumber-0.14 / -0.52Pattern offset.
colorsColorConfigUnified colour override.
animationAnimationConfigUnified animation override.

type="mesh-gradient"

PropTypeDefaultDescription
colors[string,string,string,string]theme-awareFour gradient stop colours.
distortionnumber0.8Distortion intensity.
swirlnumber0.1Swirl strength.
speednumber1Animation speed.

type="webgl"

PropTypeDefaultDescription
shape"square" | "circle" | "triangle" | "diamond""square"Pixel art shape.
pixelSizenumber4Size of each pixel.
inkstring"#FFFFFF"Ink/foreground colour.
interactivebooleantrueEnable mouse interaction.
shapeScalenumber1.0Scale multiplier.

type="pattern"

PropTypeDefaultDescription
gridPatternGridPattern"multi-layer"Preset: multi-layer, dark-white, light-dark, minimal-white, minimal-dark, custom.
backgroundColorstringpresetBackground fill.
dotColors[string,string,string]presetDot layer colours.
dotSizes[string,string,string]presetDot sizes.
gridSizes[string,string,string]presetBackground-size per layer.
gridPositions[string,string,string]presetBackground-position per layer.

type="none"

Renders nothing. Useful for conditional switching without unmounting the component.

On this page