shadcn.io is an independent project built on shadcn/ui
Gradient Background for Vue
Wide bands of color flow along an angle and bend into soft folds. For Vue with Ark UI, when a hero needs color that moves.
On this page10 sections
Gradient runs your palette across the box in wide bands, the way a CSS gradient does, then sets it moving: slow noise bends the bands into folds, and they travel along the angle. It's a GLSL scene on WebGL2 with no dependency. Colors are mixed in OKLab, and light rides with the bands: on a light surface its crests thin toward the surface, on a dark one the troughs between them sink into it. The bands bow toward the pointer.
Use it behind a hero, a sign-in page or a pricing band, where you'd reach for a CSS gradient and want it to move; add grain for the grainy gradient look. For color that sits in areas instead of bands, use Mesh Gradient; for separate blobs that float, Gradient Animation; for one color lit like satin, Silk. With reduced motion it draws one still frame.


Installation
Usage
<script setup lang="ts">
import { Gradient } from "@/components/ui/gradient";
</script>
<template>
<Gradient class="flex min-h-[32rem] flex-col items-center justify-center gap-4">
<h1 class="text-5xl font-semibold">Automate the work between your tools</h1>
<p class="text-foreground/80">Triggers, approvals and retries, on their own.</p>
</Gradient>
</template>
Gradient is a container: what you put inside sits on top of the color, 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
<Gradient /><Gradient
:colors="['#22d3ee', '#6366f1', '#a855f7', '#ec4899']"
origin="top"
:scale="2"
type="conic"
/><Gradient
:colors="['#fb923c', '#f472b6', '#6366f1']"
:grain="0.55"
:warp="1.6"
/><Gradient
:colors="['var(--background)', '#818cf8', '#f472b6']"
:flow="0"
:scale="0.9"
type="radial"
:warp="1.2"
/><Gradient :scale="2" :softness="0" :warp="1.4" /><Gradient
:colors="['var(--foreground)', 'var(--muted-foreground)', 'var(--background)']"
:contrast="0.6"
/><Gradient
:angle="180"
:colors="['#5eead4', '#38bdf8', '#6366f1', '#1e3a8a']"
:flow="0.5"
:warp="0.8"
/><Gradient
:colors="['#fde68a', '#fb923c', '#f43f5e', '#7c3aed']"
:flow="0"
origin="bottom"
:scale="0.9"
type="radial"
:warp="0.6"
/>stream is the default. grainy lays grain={0.55} over orange, pink and indigo, the look of a printed poster. layers sets softness to 0, so each color is a flat band with a crisp edge, like cut paper. halo is a radial gradient whose first color is var(--background): the middle of the box stays the surface and the color rings it, which leaves a headline plain ground to sit on. sunrise rings the palette around the bottom edge and holds it there with flow={0}.
Examples
Hero
A badge, a headline, one line of copy and two links, centered over the default look with no props. The scene holds every color to a tone copy can sit on, so the headline in text-foreground reads in both themes; the secondary link gets bg-background/60 backdrop-blur.
Grain
grain={0.55} over three colors, orange, pink and indigo, with warp={1.6} for longer bends. grain is the engine's own prop, so it works on every background, but this is the one it's known for.
Card
type="radial" with origin="top" rings the palette around the top edge of the card: pale yellow at the origin, then orange, rose and violet toward the copy. flow={0} holds the rings in place, so they only bend.
Customization
colors takes two to eight CSS colors, in the order the bands run: hex, oklch(), color-mix() or a theme variable such as var(--primary), read again when the theme changes. The palette runs first to last and back again, so only neighbors in your list ever blend and the loop has no seam. type, angle and origin work as they do in CSS: linear along an angle, radial out from a point, conic around it. scale sets how many times the palette crosses the box, warp and detail how far the bands bend, and softness how widely one color melts into the next.
The scene has no background of its own. It paints over the root's background, bg-background by default, and reads it: a class such as bg-slate-950 on the root switches it to the deep tones it uses on a dark surface, and that color shows in the troughs. fade fades one edge into the surface, grain adds film grain and opacity thins the whole scene.
<Gradient
angle={90}
className="min-h-svh bg-slate-950"
colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-4)"]}
fade="bottom"
grain={0.3}
/>Performance
It's one WebGL2 canvas and a shared runtime with no dependency. Each pixel costs three samples of simplex noise and two palette colors converted to OKLab, with no loop, no ray march and no simulation, which makes it one of the lightest scenes in the collection. It animates only while it's on screen and the tab is visible, and it lowers its own resolution, down to half, when frames run long. quality sets the render scale by hand, which costs little here because the bands have no fine detail, and paused holds the current frame.
Accessibility
The canvas is decoration: it's aria-hidden and lets every click through to your content. With reduced motion it draws one still frame, the scene at 6 seconds, and doesn't animate or follow the pointer.
Put copy over it in text-foreground. At the defaults the lowest contrast anywhere in the box, measured on the frames we shot, is 5.4:1 on a light surface and 5.3:1 on a dark one. The hold works on lightness, so it applies to your own palette too: no color goes deeper than 0.64 in OKLab lightness on a light surface, or brighter than 0.545 on a dark one. Above intensity={1} the scene stops holding that tone, so check your contrast there. Nothing flashes.
FAQ
How do I change the colors?
Pass two to eight CSS colors to colors, in the order the bands should run, such as colors={["#fb923c", "#f472b6", "#6366f1"]}. Any CSS color works, theme variables included, and they are read again when the theme changes. The palette runs first to last and then back, so the last color never has to blend into the first.
Can it be radial or conic, like a CSS gradient?
Yes. type="radial" rings the palette around a point and type="conic" fans it out around one; origin puts that point in the middle of the box or the middle of an edge. angle uses the CSS convention: 0 runs to the top and 90 to the right. With warp={0} and flow={0} it's the plain CSS gradient, drawn in OKLab.
How do I get the grainy gradient look?
Set grain, from 0 to 1: grain={0.5} is the heavy film grain of a printed poster and 0.2 is a light texture. The grain is drawn about one CSS pixel wide over the scene, light specks and dark ones, so it also hides any banding a display would add. The grainy preset is a starting point.
Why are the colors lighter or deeper than the ones I passed?
At intensity={1} the scene holds a tone copy can sit on: on a light surface it lifts dark colors, on a dark surface it lowers bright ones. Hue stays, with one exception: on a dark surface an orange or a yellow turns toward red as it deepens, because a dark orange is brown. Raise intensity toward 2 to show the palette as written, and check your text contrast when you do.
Does it work in light and dark mode?
Yes, with no props. The scene reads the surface behind it. On a light one the colors stay light and the crests of the light thin toward the surface. On a dark one the colors go deep and the troughs sink into the surface, so the bands read as folds with shadow between them. The surface is the root's background, so bg-slate-950 or your own color works the same way.
Can the bands bend without traveling across the box?
Yes: flow={0}. The palette then holds its place, which matters when a color should stay put, such as the pale center of a radial gradient behind a headline, and the bands still bend on slow noise. speed={0} stops everything, and paused holds whichever frame is showing.
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, because the runtime 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, and does it work with server rendering?
It's a light shader: three noise samples a pixel, on the GPU, and nothing while it's off screen or the tab is hidden. On phones the pixel ratio is capped at 2 and touch never moves the bands, so scrolling isn't disturbed. The server renders a div and an empty canvas, and the scene starts once it mounts; until then, and without WebGL2, the box shows fallback, such as a CSS linear-gradient() of your colors.
API Reference
Gradient
data-slot="gradient"
angle?number
The direction the palette runs and the bands travel, in degrees as in a CSS gradient: 0 runs to the top, 90 to the right. A conic gradient starts its sweep there.
- Default
135
colors?string[]
Two to eight CSS colors, in the order the bands run. The palette runs
first to last and back, so only neighbors in the list ever blend. Theme
variables such as var(--primary) follow your theme.
- Default
["#fb923c", "#f472b6", "#6366f1", "#38bdf8"]
contrast?number
How much the folds are lit, from 0 (flat color) to 2: where the bands bunch up they deepen, where they stretch out they lighten.
- Default
1
detail?number
How much fine ripple the bands carry on top of their broad bends, from 0 to 1.
- Default
0.5
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.
flow?number
How fast the bands travel along the angle, from 0 (they hold their place and only bend) to 2.
- Default
1
grain?number
Film grain over the scene, from 0 to 1.
- Default
0
intensity?number
How strongly the color sits on the surface, from 0 to 2. Below 1 it thins toward the surface. At 1 every color is held to a tone copy reads on: light enough on a light surface, deep enough on a dark one. Toward 2 that hold lets go and the palette shows as written.
- 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
origin?"center" | "top" | "bottom" | "left" | "right"
Where a radial or conic gradient is centered: the middle of the box or the middle of one of its edges. A linear gradient ignores it.
- Type
"center" | "top" | "bottom" | "left" | "right"- Default
"center"
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
How many times the palette runs across the box: higher packs more, narrower bands. A conic gradient rounds it to a whole number.
- Default
1
seed?number
Another layout of the bends, from 0 to 20.
- Default
0
softness?number
How widely each color melts into the next, from 0 (flat bands with a crisp edge) to 1 (one continuous blend).
- Default
1
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.
type?"linear" | "radial" | "conic"
The shape of the bands: linear runs them across the box, radial
rings them around the origin, conic fans them out from it.
- Type
"linear" | "radial" | "conic"- Default
"linear"
warp?number
How far slow noise bends the bands, from 0 (straight, as in CSS) to 2.
- Default
1











