Skip to content

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

Pro

Kaleidoscope Background for Vue

Colored glass drifts under a ring of mirrors, folded into soft wedges. For Vue with Ark UI, when a hero wants symmetry and color.

On this page10 sections
UI library: Ark UI

Two sheets of colored glass drift under a ring of mirrors, which fold them into wedges around a center: large shards edge to edge, and a few small chips lying across them. Each wedge is shaded like the face of a cut stone, a thin light runs along the mirrors, and the colors mix in OKLab. It's a GLSL scene on WebGL2 with no dependency. The glass is a pastel wash on a light surface and deep color on a dark one, and the pointer slides it under the mirrors.

Use it behind a centered hero or a sign-up section: by default the area around the center stays calm, so the figure frames the copy. For soft blobs of color with no symmetry, use Mesh Gradient; for flat cells that drift and reshape, Voronoi; for a faceted low-poly sheet under a moving light, Facets. With reduced motion it holds one still frame.

Playground
Kaleidoscope 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

<script setup lang="ts">
import { Kaleidoscope } from "@/components/ui/kaleidoscope";
</script>
<template>
  <Kaleidoscope class="flex min-h-[36rem] flex-col items-center justify-center">
    <h1 class="text-5xl font-semibold">One palette, every surface</h1>
  </Kaleidoscope>
</template>

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

Iristhe default lookTry it
<Kaleidoscope />
EmeraldTry it
<Kaleidoscope
  :colors="['#065f46', '#10b981', '#5eead4', '#a7f3d0']"
  :rotation="18"
  :segments="5"
/>
Lacethe default lookTry it
<Kaleidoscope :hub="0.9" :scale="2.2" :segments="12" :softness="0.3" />
MistTry it
<Kaleidoscope
  :colors="['#38bdf8', '#818cf8', '#e0e7ff']"
  :facets="0.15"
  :hub="0"
  :intensity="0.6"
  :scale="0.6"
  :seams="0"
  :segments="4"
  :softness="1"
/>
MonoTry it
<Kaleidoscope
  :colors="['var(--foreground)', 'var(--muted-foreground)', 'var(--border)']"
  :intensity="0.5"
  :seams="0.6"
/>
RoseTry it
<Kaleidoscope
  :colors="['#1e40af', '#2563eb', '#7c3aed', '#db2777']"
  :facets="0.7"
  :hub="0"
  :seams="0.8"
  :segments="8"
  :softness="0.1"
/>
SunriseTry it
<Kaleidoscope
  :centerY="1.05"
  :colors="['#f97316', '#fb7185', '#fbbf24', '#fde68a']"
  fade="top"
  :hub="0"
  :segments="9"
/>

Each preset is a set of props, so copy one and keep tuning. Iris is the default. Rose fills the box with flat chips, heavy seams and eight repeats, like a rose window; Lace packs small shards into twelve; Mist melts the glass into one soft gradient with four-fold symmetry; Sunrise puts the center under the bottom edge, so the wedges fan up from it; and Mono takes its colors from your theme.

Examples

Hero

The default look with no props: the copy is centered on the figure, in the calm area that hub keeps around the center, and the glass shows at full strength toward the edges. The chip and the second button have a translucent ground of their own.

Preview width

Rose

hub={0} fills the whole box, softness={0.1} keeps the shards flat, and seams={0.8} and facets={0.7} draw the mirrors, with eight repeats in blue, violet and magenta on a slate surface.

Preview width

In a card

centerY={1.05} puts the center just under the card, so nine wedges fan up from its bottom edge, and the engine's fade="top" clears the top of the card for the copy.

Preview width

Customization

colors takes two to eight CSS colors, theme variables included: each shard takes one of them, and where shards overlap or melt together they mix in OKLab. Colors from one side of the wheel stay clean; opposite hues, such as blue and orange, meet in grey. segments sets the symmetry, softness runs from flat chips to one gradient, and centerX and centerY move the figure, off the box if you like.

The surface is the root's own background, bg-background by default. Give the root another (bg-slate-950, a gradient) and the scene adapts: the glass adds light to a dark surface and tints a light one. fade masks an edge, opacity turns the whole effect down, and grain adds film grain.

<Kaleidoscope
  className="min-h-[32rem] bg-slate-950"
  colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-3)"]}
  grain={0.15}
  segments={8}
/>

Performance

It's one WebGL2 canvas and one fragment shader: each pixel folds its angle into one wedge, then reads two sheets of glass, nine shards each, plus two samples of simplex noise for the bend. There are no textures and no feedback. 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 figure 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: the glass drifts a shard's width in about half a minute.

Keep copy in the calm area around the center. With the default look, text in text-foreground there measures 10:1 or more on a light surface and 11:1 or more on a dark one. Outside it, on a light surface the pastel glass still leaves dark text above 5:1, but on a dark surface white text over the lightest shards falls to about 3:1. Raise hub for a wider calm area, or lower intensity.

FAQ

How do I change the colors?

Pass two to eight CSS colors to colors. Each shard of glass takes one of them, so the order doesn't matter. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes. Pick hues from one side of the color wheel: the glass overlaps and blends, and opposite hues blend to grey.

Does it work on a light page?

Yes, with no prop to set. The scene reads the color behind it: on a light surface the glass is a pastel tint, at about 60% of each color, and on a dark one it adds light, so the same palette reads as deep glass. Set the surface with a class on the component, such as bg-slate-950.

How do I keep my headline readable in the middle?

That is what hub is for. It keeps a calm ellipse around the center, shaped like the box, where the glass shows at about an eighth of its strength, and the default of 0.75 covers a centered headline, a line of copy and two buttons. Raise it toward 1.5 for longer copy, or set it to 0 to fill the box when nothing sits on top.

How many mirrors does it have?

segments is how many times the pattern repeats around the center, from 3 to 12, and each repeat is a wedge and its mirror image: 6, the default, gives twelve wedges and a six-pointed figure. Low numbers read as large petals, high numbers as lace, especially with a higher scale.

How do I put it behind the whole page?

Render it empty with className="fixed inset-0 -z-10". It still follows 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.

Will it slow my page down?

It is a mid-weight scene: 18 shard lookups and two noise samples a pixel, with no loop that grows with any prop, so every setting costs the same. Off screen and in a hidden tab it draws nothing, and if a device can't keep up it renders fewer pixels by itself. quality={0.75} does that from the start.

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 does the pointer do, and can I turn it off?

Moving the pointer slides the glass under the mirrors, as if you turned the tube, so the whole figure reshapes while its symmetry holds. Touch never moves it, so scrolling on a phone isn't disturbed. interactive={false} turns it off, and spin={0} stops the figure from turning by itself while the glass keeps drifting.

API Reference

Kaleidoscope

data-slot="kaleidoscope"

PropType
centerX?number

Where the center of the figure sits across the box, from 0 (the left edge) to 1 (the right edge); down to -0.2 or up to 1.2 puts it outside the box.

Default
0.5
centerY?number

Where the center of the figure sits down the box, from 0 (the top) to 1 (the bottom); down to -0.2 or up to 1.2 puts it outside the box.

Default
0.5
colors?string[]

Two to eight CSS colors for the glass: each shard takes one of them. Theme variables such as var(--primary) follow your theme.

Default
["#4338ca", "#6d8bff", "#b9a7ff", "#f7a8d8"]
facets?number

How strongly each wedge is shaded from one mirror to the next, from 0 (flat) to 1, like the faces of a cut stone.

Default
0.4
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.

grain?number

Film grain over the scene, from 0 to 1.

Default
0
hub?number

The size of the calm area around the center, where copy sits, from 0 (none) to 1.5.

Default
0.75
intensity?number

How strongly the glass shows, from 0 to 2.

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

How far the figure is turned, in degrees, from -180 to 180.

Default
0
scale?number

The size of the shards: higher packs more of them into each wedge.

Default
1
seams?number

How strongly a thin line of light shows along the mirrors, from 0 to 1.

Default
0.3
seed?number

Another arrangement of the same glass, a whole number from 0 to 20.

Default
0
segments?number

How many times the pattern repeats around the center, from 3 to 12: each repeat is a wedge and its mirror image.

Default
6
softness?number

How far the shards melt into each other, from 0 (flat chips of glass) to 1 (one soft gradient).

Default
0.35
speed?number

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

Default
1
spin?number

How fast the figure turns by itself, from -2 to 2: 0 holds it still while the glass drifts under the mirrors.

Default
0.5
time?number

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

warp?number

How much the glass bends on its way through the mirrors, from 0 to 1.

Default
0.5