Appica UIUI 1.0.0

Background Pattern

A decorative pattern behind your content, with an optional cursor-following spotlight.

Move your cursor over the panel

Usage

BackgroundPattern is a <div> wrapper that paints a subtle, masked pattern behind its children. Pick a texture with the variant prop — dots (the default), grid, dashed-grid, or hexagons — and tune its density with cellSize. The pattern is drawn from the --pattern-color CSS variable (defaulting to the --color-border-intense token) via currentColor masks, so it stays muted against either light or dark surfaces; override that variable to recolor it.

Enable spotlight to add a radial highlight that follows the cursor and brightens the pattern nearby; pass true for the default, a number/length to size it, or { persistent: true } to keep it always on. The decorative layers are aria-hidden, so they never interfere with assistive tech — your children remain fully accessible, and the wrapper accepts className, style, and any native <div> attributes.

Examples

Variants

Four textures cover the common cases: scattered dots, a ruled grid, a finer dashed-grid, and a hexagons mesh. Each carries a sensible default cell size, drawn at low opacity so content stays legible.

Spotlight

Set spotlight to add a cursor-following highlight that brightens the pattern near the pointer and fades out when the cursor stops. Move your cursor over the panel to see it react.

Persistent / sized spotlight

Pass an object to keep the highlight always on with { persistent: true } and size it with size (a number in px, or any CSS length). A persistent spotlight skips the fade entirely.

Custom cell size

cellSize overrides the per-variant default to make the texture denser or airier. Here the same grid variant is shown at two scales.

Custom color

The pattern reads its color from the --pattern-color CSS variable, which defaults to the muted --color-border-intense token. Set it to recolor the texture — point it at a theme token like var(--primary), or drop in any custom value. Here a bluish-purple hex tints the pattern and its spotlight, paired with a matching surface mixed from the same hue and var(--background) via color-mix, so the wash stays subtle in both light and dark mode.

API reference

BackgroundPattern renders a <div> and forwards every remaining native <div> attribute. The decorative pattern and spotlight layers are aria-hidden. Set the --pattern-color CSS variable (via className or style) to recolor the texture — see Custom color.

Accessibility

  • The pattern and spotlight layers are aria-hidden and pointer-events-none, so they're skipped by assistive tech and never intercept clicks.
  • Content is wrapped, not replaced — your children stay in the normal flow and fully accessible.
  • The pattern is intentionally low-emphasis; ensure your foreground content keeps sufficient contrast against the background for it to stay readable.
  • The cursor spotlight honours prefers-reduced-motion — it's forced persistent (fade-free) when a user requests reduced motion.

© 2026 Appica UI. A free component library, crafted by the Appica team.