Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Bokeh Background for React

Soft, out-of-focus circles of light that drift and gently breathe, like the background of a portrait photo. For React with Base UI, when a hero should feel warm, calm and photographic.

Framework

Bokeh fills the box with soft, out-of-focus circles of light, like the background of a portrait photo. Far lights are small soft glows in amber, peach and gold; near ones are large lens discs in rose and coral, with a teal accent, each a little brighter at its rim, the outline real bokeh has. Every light drifts slowly on its own loop and gently grows and dims. On a light page they read as warm light leaks; in dark mode they're more saturated and add up where they overlap, so they glow instead of turning brown. Every orb is radial gradients placed when the page renders and moved by CSS keyframes, with no blur filter and no script.

Use it behind a warm, photographic hero. For glassy soap bubbles use Bubbles; for large colour blobs with no edges, Gradient; for small glowing points that blink, Fireflies; for tiny motes in a light shaft, Pollen.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { Bokeh } from "@/components/ui/bokeh";
<Bokeh className="min-h-[420px]">
  <h1>In soft focus</h1>
</Bokeh>

Bokeh is a container: put your content inside and the lights drift behind it. It fills the box you give it, so set its height (min-h-[420px]), or className="fixed inset-0 -z-10" to cover the whole page. It has no background of its own: on a dark container the lights glow, on a light page they read as soft light leaks.

Demos

City lights

colors takes any CSS colours, picked for each orb. A cool palette at intensity="strong" on a dark container looks like city lights at night.

Preview width

Inside a card

Fewer, smaller orbs (count={10}, minSize={24}, maxSize={90}), so whatever you put in the card stays the focus.

Preview width

Accessibility

The lights are decoration: the whole layer is hidden from screen readers and ignores the pointer, and your content inside reads as usual. With reduced motion every orb holds its place and size, a still photograph of the lights. Nothing flashes: the breathing is a slow fade over 7 to 19 seconds.

Keep text in the foreground colour. On a light page the lights stay pale enough for dark text at every intensity. In dark mode a bright far glow under white text can bring contrast near 4.5:1 at the default medium and below it at strong, so use subtle behind text-heavy heroes.

FAQ

What is bokeh?

The soft circles that out-of-focus lights make in a photo with a shallow depth of field. Far lights blur into small soft glows; near ones into large flat discs with a slightly brighter edge. This draws both with radial gradients.

Can I change the colours?

colors takes any CSS colours, theme variables included, picked for each orb. The default palette is tuned per theme, and each colour is a variable (--bokeh-color-1 to --bokeh-color-6: amber, rose, peach, gold, teal and coral) you can set from CSS.

Why do the lights look different in dark mode?

Warm light that's dim turns brown, so at night the palette is more saturated and the orbs blend with plus-lighter: where two overlap their light adds up, as it does in a photo. The large near discs take rose, coral and teal, which stay luminous when dim.

How many orbs?

count sets them: 24 by default, up to 40. Fewer and larger feels calmer.

Can I change their size?

minSize and maxSize set the range in pixels (48 to 200 by default). The larger orbs sit in front, drift further and become lens discs, like nearer lights.

Will text on top stay readable?

Use intensity="subtle" behind body text, especially in dark mode; speed below 1 slows the drift if it distracts.

Does it respect reduced motion?

Yes: the orbs hold their place and size. Nothing flashes.

API Reference

Bokeh

<div> data-slot="bokeh"

PropType
colors?string[]

The lights' colours, any CSS colours, dealt to the orbs in turn. By default warm golds and peaches; theme variables such as var(--primary) work too.

count?number

How many orbs, from 0 to 40. @default 24.

Default
24
intensity?"subtle" | "medium" | "strong"

How strongly the orbs show: subtle behind body text, strong on a dark scene.

Type
"subtle" | "medium" | "strong"
Default
"medium"
maxSize?number

The largest orb's diameter, in pixels; the larger orbs sit in front. @default 200.

minSize?number

The smallest orb's diameter, in pixels. @default 48.

speed?number

How fast the orbs drift and breathe, as a multiplier: 0.5 is slower. @default 1.

render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--bokeh-alphastring

The orbs' strength, from 0 to 0.8 (0.42; 0.5 in dark mode).

--bokeh-color-1string

The first palette colour (amber); -2 to -6 are rose, peach, gold, a teal accent and coral, each tuned for light and dark mode.

--bokeh-maxstring

The largest orb's diameter (200px).

--bokeh-minstring

The smallest orb's diameter (48px).

--bokeh-speedstring

How fast the orbs drift and breathe, a multiplier (1).

All 100 backgrounds