Skip to content

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

Pro

Shapes Background for Solid

Circles, squares, triangles and rings float in depth, blurred with distance. For Solid with Ark UI, when an onboarding page needs a friendly backdrop.

On this page10 sections
UI library: Ark UI

Circles, rounded squares, rounded triangles and rings float at three depths: a few large, pale, out-of-focus ones far away, medium ones between, and small crisp ones near, each with a soft halo of its own color. They drift, turn slowly, and grow in and shrink away in their own places, so nothing pops. It's a GLSL scene on WebGL2 with no dependency. The shapes are flat color from a palette of four, the same on a light or a dark surface, and the depths shift a little with the pointer.

Use it behind a product hero, an onboarding step, an empty state or a sign-up card. The crisp shapes leave the middle of the box clear, so centered copy stays readable. For out-of-focus discs of light with no hard edges, use Bokeh; for small dots drifting in depth, Particles; for paper tumbling down at a launch, Confetti. With reduced motion it holds one still frame.

Playground
Shapes 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 { Shapes } from "@/components/ui/shapes";
<Shapes class="flex min-h-[32rem] flex-col items-center justify-center">
  <h1 class="text-5xl font-semibold">Welcome aboard</h1>
</Shapes>

Shapes is a container: whatever you put inside sits on top of the scene, 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

Playfulthe default lookTry it
<Shapes />
Hazethe default lookTry it
<Shapes
  blur={1}
  clearing={0.3}
  density={0.9}
  glow={1}
  intensity={0.7}
  outline={0}
  scale={0.7}
  size={1.4}
/>
HoopsTry it
<Shapes
  clearing={0.4}
  colors={["#22d3ee", "#a78bfa"]}
  outline={1}
  shapes="rings"
/>
MemphisTry it
<Shapes
  blur={0}
  colors={["#ff5c5c", "#ffc93c", "#3d5afe", "#1de9b6"]}
  lineWidth={3}
  outline={0.5}
  shapes="angular"
  spin={1.6}
/>
MonoTry it
<Shapes
  blur={0}
  colors={["var(--foreground)", "var(--muted-foreground)"]}
  glow={0}
  intensity={0.6}
  lineWidth={1.5}
  outline={1}
/>
<Shapes
  colors={["#38bdf8", "#818cf8", "#f472b6"]}
  shapes="round"
  size={1.3}
/>
Sprinklethe default lookTry it
<Shapes density={1} drift={1.6} scale={1.8} size={0.8} />

Each preset is a set of props, so copy one and keep tuning. Playful is the default. Haze blurs and enlarges everything into a soft wash, Sprinkle packs many small shapes like a party page, Memphis is squares and triangles with thick outlines and no blur, and Mono draws thin outlines in your theme's foreground color.

Examples

Hero

The default look with centered copy. The crisp shapes shrink to nothing over the middle of the box (clearing), so only the pale, out-of-focus ones pass behind the headline, at half strength.

Preview width

Outline

outline={1} draws every crisp shape as a line, here lineWidth={2.5}, with a faint tint inside from its halo. The out-of-focus shapes stay filled, since a blurred line would only be a smudge. clearing={0.5} lets half-size shapes into the middle.

Preview width

In a card

shapes="round" keeps the circles and rings, scale={1.3} packs smaller ones into the small box, and three colors replace the palette. clearing={0} fills the whole card and fade="bottom" thins the scene out behind the text.

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)", "var(--chart-3)"]}. Neighboring shapes never share a color: the palette steps across the layout. shapes picks the set, outline the share drawn as lines, blur how out of focus the far ones are, and seed gives another layout.

The surface is the root's own background, bg-background by default. Give the root another (bg-slate-950, a tint, a gradient) and the same shapes sit on it. clearing sets how much room the middle keeps for copy, fade masks an edge, opacity turns the whole scene down, and grain adds film grain.

<Shapes
  class="min-h-[32rem]"
  colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-4)"]}
  outline={0.6}
  shapes="round"
/>

Performance

It's one WebGL2 canvas and one fragment shader with no noise and no march: each pixel tests the four nearest places at each of three depths, twelve shapes at most, and skips the empty ones. 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 scene is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion it draws one still frame and ignores the pointer. Nothing flashes: a shape takes a few seconds to grow in or shrink away, and the fastest one needs 42 seconds for a full turn.

A crisp shape is solid color, so text must not cross one. With the default clearing the middle of the box stays free of them: 72% of its width and 60% of its height, up to 760 by 400 CSS pixels. Over the hero demo's copy, foreground text measured 12.6:1 at worst on a light surface and 5.3:1 on a dark one, where a pale out-of-focus shape passes behind it. If your copy sits elsewhere, mask that side with fade or lower intensity.

FAQ

How do I change the colors?

Pass two to eight CSS colors to colors. Each shape takes one of them, and the palette steps across the layout so two neighbors never match. Hex, oklch() and theme variables such as var(--chart-1) all work, and a variable follows your theme when it changes. Two or three colors look calmer than six.

Can I show only circles, or only outlines?

shapes picks the set: mixed, round (circles and rings), angular (squares and triangles), or one kind: circles, squares, triangles, rings. outline is the share of crisp shapes drawn as lines, from 0 (all filled) to 1 (all outlined), and lineWidth is the line in CSS pixels. Out-of-focus shapes stay filled; blur={0} outlines them too.

How do I keep shapes away from my text?

Centered copy needs nothing: with clearing={1}, the default, crisp shapes shrink to nothing over the middle of the box and the soft ones pale. For copy at one edge, as in a card, set clearing={0} and mask that edge with fade, such as fade="bottom". Lower density leaves more empty places everywhere.

Does it work in dark mode?

Yes, with no prop to set. The shapes are pigment, not light: the same colors cover a white surface and a near-black one. The far, out-of-focus shapes are drawn a little weaker on dark so they stay behind the copy. For shapes that follow the theme, pass theme variables to colors, as the Mono preset does.

How do I put it behind the whole page?

Render it empty with className="fixed inset-0 -z-10". The depths still shift with the pointer there, since the scene listens on the window. Shape sizes follow the box up to a 760 pixel shorter side and then hold, so a large page gets more shapes, not giant ones.

Will it slow my page down?

It's a light shader: at most twelve shape tests a pixel and no noise. It runs on the GPU, stops while it's off screen or the tab is hidden, and renders fewer pixels by itself if a device can't keep up. For a phone-first page, quality={0.75} 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, and on touch screens?

With reduced motion it draws one still frame, the same layout on every visit, and the pointer no longer shifts the depths. On a touch screen the shapes drift and turn as usual but touch never moves them, so scrolling isn't disturbed. drift={0} and spin={0} keep the shapes in place while they still grow in and shrink away.

API Reference

Shapes

data-slot="shapes"

PropType
angle?number

The direction the shapes drift, in degrees: 0 is to the right, 90 is up.

Default
60
blur?number

How out of focus the far shapes are, from 0 (every shape crisp) to 1. The near ones stay sharp.

Default
0.6
clearing?number

How much room the shapes leave in the middle of the box, where copy sits: from 0 (none) to 1, where the crisp ones shrink to nothing there and the soft ones pale.

Default
1
colors?string[]

Two to eight CSS colors. Each shape takes one of them. Theme variables such as var(--chart-1) follow your theme.

Default
["#6366f1", "#f472b6", "#fbbf24", "#2dd4bf"]
density?number

How many shapes show at once, from 0.1 (a few) to 1 (one in every place).

Default
0.8
drift?number

How fast the shapes travel, the near ones faster than the far ones. 0 keeps them in place.

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.

glow?number

The soft halo of its own color around each crisp shape, from 0 (none) to 1.

Default
0.5
grain?number

Film grain over the scene, from 0 to 1.

Default
0
intensity?number

How strongly the shapes show.

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
lineWidth?number

The width of an outlined shape's line, in CSS pixels.

Default
2
opacity?number

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

Default
1
outline?number

The share of shapes drawn as outlines, from 0 (all filled) to 1 (all outlined). Out-of-focus shapes stay filled.

Default
0.3
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
scale?number

Zoom: higher packs more, smaller shapes into the box.

Default
1
seed?number

Another layout of the same look, from 0 to 20.

Default
0
shapes?| "mixed" | "round" | "angular" | "circles" | "squares" | "triangles" | "rings"

Which shapes appear: all four, the round ones (circles and rings), the angular ones (squares and triangles), or one kind only.

Type
| "mixed" | "round" | "angular" | "circles" | "squares" | "triangles" | "rings"
Default
"mixed"
size?number

How large the shapes are for the room they have.

Default
1
speed?number

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

Default
1
spin?number

How fast the shapes turn. 0 keeps them as they are.

Default
1
time?number

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