Aurora Background for React

Living aurora background with multiple variants. Sunset, ocean, forest, lavender, ember, ice.

Component

Aurora

Installation

 

Usage

Import

Add the AuroraBackground import.

import { AuroraBackground } from "@/components/aurora-background";

Use

Use with variant and children.

<AuroraBackground variant="sunset">
  Content
</AuroraBackground>;

Guidelines

  • Variants: default, sunset, ocean, forest, lavender, ember, ice, custom.
  • For custom variant, pass colors array of CSS color strings.
  • speed and blobCount control animation.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
classNamestring-Additional CSS classes.
variantstring"default"Variant: default, sunset, ocean, forest, lavender, ember, ice, custom.
colorsstring[]-Custom colors (required when variant='custom').
speednumber4Animation speed multiplier.
blobCountnumber4Number of animated blobs.
childrenClassNamestring-Classes for the children wrapper.

Accessibility

  • Purely decorative canvas effect with no interactive controls, buttons, inputs, or focusable elements of its own.
  • Any children passed through are rendered in a plain wrapper, so their own keyboard operability and focus visibility are the consumer's responsibility.
  • The canvas element carries no role, aria-hidden, or aria-label, so consider marking it aria-hidden since it conveys no information to assistive tech.
  • It does not check prefers-reduced-motion, so the rAF loop should be guarded with matchMedia('(prefers-reduced-motion: reduce)') to pause or skip the animation for users who prefer reduced motion.

Performance

  • Each frame clears the full canvas and runs a full-size fillRect per blob plus up to two screen-blend passes, with a fresh radial gradient created every iteration, so the cost scales with blobCount and canvas area on the main thread.
  • This is CPU-bound 2D canvas rasterization rather than cheap GPU-composited transform or opacity animation, so larger surfaces and higher blobCount get expensive.
  • The animation is driven by requestAnimationFrame, which throttles to the display refresh and pauses on inactive tabs.
  • There is no IntersectionObserver or visibility gating, so it keeps redrawing even when scrolled off-screen.
  • Cleanup is handled correctly: the effect cancels the rAF and removes the resize listener on unmount or dependency change.

Examples

Default

Default aurora variant.

Aurora
import { AuroraBackground } from "@/components/aurora-background";

<AuroraBackground variant="default" className="h-32">
  <div className="flex h-full items-center justify-center">
    Content
  </div>
</AuroraBackground>;

Custom colors

Custom colors with variant='custom'.

Aurora
import { AuroraBackground } from "@/components/aurora-background";

<AuroraBackground
  variant="custom"
  colors={[
    "hsla(180, 80%, 50%, 0.5)",
    "hsla(200, 70%, 45%, 0.3)",
    "transparent",
  ]}
  className="h-32"
>
  Content
</AuroraBackground>;

Last updated on Jun 19

Made with ❤️ by Pulkit &

© 2026 Pulkit. All rights reserved

Last updated: