Skip to content

shadcn.io is an independent project built on shadcn/ui

Pro

Bokeh Background for Solid

Out-of-focus lights drift in depth as soft discs with a brighter rim. For Solid with Ark UI, when a hero needs warmth behind its copy.

On this page10 sections
UI library: Ark UI

Out-of-focus lights fill the box: soft discs with a brighter rim, in four layers from a few large faint ones in front to many small ones behind. Each light wanders, breathes and goes out for a while now and then, and the palette runs across the box, warm on one side and cool on the other. It's a GLSL scene on WebGL2 with no dependency. On a dark surface the discs add up like light; on a light one they're soft tints. The pointer shifts the layers against each other.

Use it behind a hero for a venue, an event or anything that should feel like evening. For soap bubbles with a film and a highlight, use Bubbles; for large blobs of color that merge with no edge, Gradient Animation; for small sharp dots drifting in depth, Particles. With reduced motion it holds one still frame.

Playground
Bokeh Background, still
Customize

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 class="flex min-h-[32rem] flex-col items-center justify-center">
  <h1 class="text-5xl font-semibold">Dinner on the roof, above the lights</h1>
</Bokeh>

Bokeh is a container: whatever you put inside sits on top of the lights, in normal flow. It fills its own box, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".

Presets

Lightsthe default lookTry it
<Bokeh />
GoldenTry it
<Bokeh
  colors={["#ffb340", "#ff8f4d", "#ffcf5c"]}
  density={1.4}
  edge={1.4}
  scatter={1}
  size={70}
/>
LensTry it
<Bokeh
  blur={0.08}
  colors={["#4fd1c5", "#5c9dff", "#a98bff"]}
  edge={1.6}
  fill={0.6}
  shape="hexagon"
/>
Mistthe default lookTry it
<Bokeh
  blur={1}
  density={0.8}
  drift={0.5}
  edge={0}
  haze={1}
  size={150}
/>
MonoTry it
<Bokeh
  colors={["var(--foreground)", "var(--muted-foreground)"]}
  haze={0}
  intensity={0.6}
/>
NeonTry it
<Bokeh
  colors={["#ff3d9a", "#7a5cff", "#22d3ee"]}
  density={1.6}
  edge={2}
  fill={0.35}
  scatter={1}
  size={60}
/>
Ringsthe default lookTry it
<Bokeh blur={0.1} density={1.5} edge={2} fill={0.05} size={70} />

Each preset is a set of props, so copy one and keep tuning. Lights is the default. Golden packs smaller discs in three golds with the colors shuffled, Lens stops the lens down to crisp hexagons in teal, blue and violet, Rings empties the discs and leaves their rims, Mist blurs every edge away into large soft blobs, and Mono takes its two colors from your theme.

Examples

Hero

The copy sits in the middle of the box, right over the lights. On a dark surface the scene holds its brightest overlap under the level where the foreground color stops being readable, so the headline needs no scrim. The chip and the second button have a translucent ground of their own.

Preview width

Lens

shape="hexagon" gives every light the six sides of a lens stopped down. Here the edges are crisp (blur={0.08}), the rims brighter (edge={1.6}) and the insides thinner (fill={0.6}), in teal, blue and violet on a dark surface.

Preview width

In a card

Three golds with scatter={1}, so every light takes a random one of them, at size={48} and density={1.4} to suit a 24rem card. fade="bottom" thins the lights out toward the lower edge, where the copy sits.

Preview width

Customization

Every color is a CSS color, so a theme variable works and follows a theme switch: colors={["var(--chart-1)", "var(--chart-2)"]}. The list runs across the box from the lower left to the upper right, and scatter shuffles it: 0 keeps each color in its own part of the box, 1 gives every light a random one. size, blur, edge, fill and shape set what a disc looks like; density and depth how many there are and how far apart the layers sit; haze is the faint wash of color behind them.

The surface is the root's own background, bg-background by default. Give the root another (bg-slate-950, an image, a gradient) and the lights adapt: they add to a dark surface and tint a light one in a deeper tone. fade masks an edge, opacity turns the whole effect down, and grain adds film grain.

<Bokeh
  class="min-h-[32rem] bg-slate-950"
  colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-4)"]}
  fade="radial"
  grain={0.15}
  size={120}
/>

Performance

It's one WebGL2 canvas and one fragment shader. The box is cut into cells at four scales, each cell holds one light, and a pixel checks the nine cells around it in each scale: 36 lights at most, nearly all of them dropped by a distance test before anything is shaded. The wash behind them is one sample of simplex noise. The cost doesn't grow with density. It draws only while it's on screen and the tab is visible, shares one frame loop with every other background on the page, and lowers its own resolution if frames run long. quality sets the render scale yourself, and paused holds the frame.

Accessibility

The lights are decoration: they're hidden from assistive tech and let every click through to your content. With reduced motion it draws one still frame and ignores the pointer. Nothing flashes: a light takes 6 to 14 seconds to come on or go out, and breathes over 10 to 25 seconds.

Put copy over it in the foreground color (text-foreground). On a dark surface the scene caps how bright any overlap gets, by color, at the level where near-white text still has 4.5:1 over it: measured on the default look, the worst pixel is 4.5:1. On a light surface the discs are pale tints and the worst pixel is 9:1. Both hold at intensity={1} and below; above it, keep body copy off the brightest lights.

FAQ

How do I change the colors?

Pass one to eight CSS colors to colors. They're laid out across the box from the lower left to the upper right, so neighbors in the list sit side by side and overlaps mix between close hues. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes. Raise scatter to shuffle the colors over the whole box.

Does it work on a light page?

Yes, with no prop to set. The scene reads the color behind it. On a dark surface the discs are light and brighten where they overlap. On a light one each disc is a soft tint in a deeper tone of its color, so amber shows as orange and pale blue as a clear blue, over a wash that stays close to white. Set the surface with a class on the component, such as bg-slate-950.

Can I put text right over the lights?

Yes. At intensity={1} the scene limits how bright any pixel gets on a dark surface, by color, so near-white text keeps 4.5:1 even where three lights overlap. On a light surface the tints are pale and dark text keeps 9:1 or more. Use text-foreground for the copy. If you raise intensity above 1, keep small text away from the brightest discs or give it a ground of its own.

How do I get hexagonal bokeh?

Set shape="hexagon". Every light takes the six-sided outline of a lens stopped down, with slightly rounded corners. It reads best with crisp edges, so lower blur to about 0.1, and a brighter rim, edge at 1.5 or more. fill={0} leaves only the outlines.

How do I put it behind the whole page?

Render it empty with className="fixed inset-0 -z-10". It still answers the pointer there, since it listens on the window. To put it behind one section, wrap that section's content in it and give it a height, such as min-h-svh. The discs are sized in pixels, so a full page shows more of them, not larger ones.

Will it slow my page down?

It's a light shader: at most 36 lights checked a pixel, most of them rejected by one distance test, and nothing at all while it's off screen or the tab is hidden. If a device can't keep up, it renders fewer pixels by itself. The discs are soft, so quality={0.75} is hard to tell apart on a phone and draws a little over half the pixels.

Does it work with Next.js and server components?

Yes. Import it into a server component and it renders its box and your content on the server; the canvas starts in the browser and fades in over the surface. It needs WebGL2, which every current browser has. Without it the box keeps its background, or the fallback you pass.

What happens with reduced motion?

It draws one still frame of the lights and stops, and the pointer no longer shifts the layers. The frame is the same one every time, so the page looks the same on each visit. paused does the same on request, and drift={0} keeps the lights in place while they still breathe.

API Reference

Bokeh

data-slot="bokeh"

PropType
angle?number

The direction the lights travel, in degrees, from -180 to 180: 0 moves them to the right, 90 upward.

Default
12
blur?number

How soft the edge of each disc is, from 0 (a crisp disc) to 1 (a blur with no edge).

Default
0.25
colors?string[]

One to eight CSS colors, laid out across the box from the lower left to the upper right, so neighbors in the list sit side by side. Theme variables such as var(--primary) follow your theme.

Default
["#ff9f43", "#ff6f91", "#a98bff", "#5c9dff"]
density?number

How many lights there are, from 0.3 to 2.5: 1 shows about 70 in a 1280 by 720 box, most of them small and far back.

Default
1
depth?number

How far apart the layers are, from 0 to 1: higher makes the far lights smaller and slower than the near ones, and the pointer shifts them more.

Default
0.7
drift?number

How fast the lights travel and wander, from 0 (they stay where they are and only breathe) to 2.

Default
1
edge?number

How bright the rim of each disc is, from 0 (an even disc) to 2.

Default
1
fade?"none" | "radial" | "top" | "bottom" | "left" | "right"

Which edges fade out to the surface: radial keeps the middle, the others name the side that fades.

Type
"none" | "radial" | "top" | "bottom" | "left" | "right"
Default
"none"
fallback?string

What shows until the first frame and in browsers without WebGL2: a CSS background value that looks like the scene.

fill?number

How solid the inside of each disc is, from 0 (only the rim, like a soap bubble) to 1.

Default
0.8
grain?number

Film grain over the scene, from 0 to 1.

Default
0
haze?number

How strong the faint wash of color behind the lights is, from 0 to 1.

Default
0.5
intensity?number

How bright the lights are, from 0 to 2. At 1 the brightest overlap still leaves foreground text readable.

Default
1
interactive?boolean

Whether the scene follows the pointer and answers a press. Touch never moves it, so scrolling a page on a phone isn't disturbed.

Default
true
opacity?number

How strongly the scene shows over the surface, from 0 to 1.

Default
1
paused?boolean

Holds the current frame.

Default
false
quality?number

Render scale, from 0.25 to 1, of the screen's pixels (capped at 2×). Lower is cheaper and softer.

Default
1
scatter?number

How much the colors are shuffled, from 0 (each light takes the color of its place across the box) to 1 (each takes a random one).

Default
0.3
shape?"circle" | "hexagon"

The shape of the lens opening every light takes: round, or six-sided like a lens stopped down.

Type
"circle" | "hexagon"
Default
"circle"
shimmer?number

How much each light breathes brighter and dimmer, from 0 to 1.

Default
0.5
size?number

The radius of the largest discs, in pixels, from 30 to 160. The lights further back are smaller.

Default
90
speed?number

Animation speed: 1 is normal, 0 holds the frame.

Default
1
time?number

A fixed moment, in seconds: draws it and doesn't animate.