Skip to content

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

Pro

Vortex Background for Vue

Streaks of light that spiral into a calm center, faster as they close in. For Vue with Ark UI, when a hero should pull the eye inward.

On this page10 sections
UI library: Ark UI

Streaks of light spiral into a center: each follows its own arm, stretches and brightens as it closes in, then fades as it reaches the calm eye. It's a GLSL scene on WebGL2 with no dependency, drawn at three distances over a soft light around the eye, and the disc leans away so it fills a wide box. It glows on a dark surface and draws in deeper tones on a light one. The center drifts toward the pointer, and a press sends a ring of light through the streaks.

Use it behind a hero that should pull the eye inward: a search box, a sign-in, one sentence. The streaks fade in the eye, so centered copy stays readable with no props, and centerX and centerY move the eye off the copy when you want it bright. For streaks that fly out of a vanishing point, use Warp; for a spiral of stars and dust, Galaxy; for paint stirred in bands of color, Swirl. With reduced motion it holds one still frame.

Playground
Vortex 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 { Vortex } from "@/components/ui/vortex";
</script>
<template>
  <Vortex class="flex min-h-[32rem] flex-col items-center justify-center">
    <h1 class="text-5xl font-semibold">Every document, one answer</h1>
  </Vortex>
</template>

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

Whirlthe default lookTry it
<Vortex />
Cometsthe default lookTry it
<Vortex
  :count="220"
  :haze="0.8"
  :length="2"
  :lineWidth="2.6"
  :twist="0.8"
/>
Drainthe default lookTry it
<Vortex :core="0" :count="900" :tilt="0" :twist="2.2" />
Dustthe default lookTry it
<Vortex
  :count="1500"
  :length="0.35"
  :lineWidth="1"
  :pull="0.7"
  :tilt="0.55"
  :twist="1.8"
/>
EmberTry it
<Vortex
  :colors="['#ff9f1c', '#ff5a36', '#e11d48']"
  :lineWidth="2"
  :pull="1.4"
  :twist="-1.6"
/>
Horizonthe default lookTry it
<Vortex :centerY="1" :core="0.5" :tilt="0.6" />
Inflowthe default lookTry it
<Vortex :core="0.3" :length="1.6" :tilt="0" :twist="0" />
MonoTry it
<Vortex
  :colors="['var(--muted-foreground)', 'var(--foreground)']"
  :haze="0"
  :lineWidth="1.2"
/>

Each preset is a set of props, so copy one and keep tuning. Whirl is the default. Drain winds the streaks all the way into a point, seen from above; Horizon sets the eye on the bottom edge, so copy sits over the slow outer streaks; and Mono takes its two colors from your theme, so it draws in near-black on a light page and near-white on a dark one.

Examples

Hero

The copy is centered over the eye, where the streaks fade out (core, 0.4 by default), and the brightest ones circle it. The demo sets no props.

Preview width

Drain

core={0} lets the streaks wind all the way in, tilt={0} shows the disc from above, and twist={2.2} winds them tighter, here with count={900} on a dark surface. The center is the brightest point of this one, so it suits a box with no copy over the middle.

Preview width

In a card

centerY={0.3} lifts the eye into the top of the card and core={0.2} makes it small; fade="bottom" thins the streaks out toward the copy. The streak count follows the size of the box, so a card shows fewer than a hero with the same count.

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 from the outer streaks to the ones by the eye, mixed in OKLab, and each streak takes a color a little to either side of its place, so two colors already give a range.

The surface is the root's own background, bg-background by default; give the root another class (bg-slate-950) and the streaks adapt. They add light to a dark surface and draw in a deeper tone on a light one. fade masks an edge, opacity turns the whole effect down, and grain adds film grain.

<template>
  <Vortex
    class="min-h-[32rem] bg-slate-950"
    :colors='["var(--chart-1)", "var(--chart-2)", "var(--chart-4)"]'
    fade="radial"
    :twist=2
  />
</template>

Performance

It's one WebGL2 canvas and one fragment shader, with no ray marching and no simulation. A pixel finds its place on the spiral with one arctangent and one logarithm, then looks at six cells at each of the three distances for a streak that covers it, so the cost stays the same at any count; the soft light around the eye is one sample of simplex noise. 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 vortex is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion it draws one still frame, ignores the pointer and sends out no ring.

Keep copy over the eye, where the streaks fade, and use the foreground color (text-foreground) for it. Toward the middle of the eye the streaks are at a fifth of their strength or less, and white text on a dark surface stays above 10:1. Outside it a streak is a line about 1.6 pixels wide, so it covers little of a letter, but along that line the contrast drops: about 2.5:1 for white text over the brightest pink streak. For long copy, raise core, lower intensity, or move the eye away with centerX and centerY. The streaks move at tens of pixels a second and nothing flashes: a press brightens a ring of them to about double as it passes.

FAQ

How do I change the colors?

Pass two to eight CSS colors to colors. The first is the outer streaks and the last is the ones closest to the center, with the rest spread between. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes. The soft light around the eye takes its color from the same list; haze={0} turns it off.

Does it work on a light page and a dark page?

Yes, with no prop to set. The scene reads the color behind it: on a dark surface the streaks add light, and on a light one they draw in a deeper tone of the same colors, like strokes of ink. Set the surface with a class on the component, such as bg-slate-950.

How do I move the center of the vortex?

centerX and centerY place it, each from 0 to 1: centerX runs from the left edge to the right, centerY from the top to the bottom. centerY={1} sets the eye on the bottom edge, so the box shows the upper half of the spiral. The center also drifts 15% of the way toward the pointer while it's over the box; interactive={false} holds it still.

Can it spin the other way, or fall straight in?

twist does both. Its sign sets the direction: a positive value winds one way, a negative value the other. Its size sets how tightly the streaks wind, up to 3, and at 0 they fall straight into the center like spokes. pull sets how fast they travel, and at pull={0} they hang where they are.

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's a light shader: about twenty cheap lookups a pixel, on the GPU, with the same cost at 100 streaks as at 1,500, 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. For a phone-first page, quality={0.75} draws a little over half the pixels; the streaks get a touch softer.

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 spiral and stops: the streaks hold their places, the center doesn't follow the pointer and a press sends out no ring. The frame is the same one every time, so the page looks the same on each visit. Touch never moves it either.

API Reference

Vortex

data-slot="vortex"

PropType
centerX?number

Where the center of the vortex sits across the box, from 0 (the left edge) to 1 (the right edge).

Default
0.5
centerY?number

Where the center of the vortex sits down the box, from 0 (the top) to 1 (the bottom).

Default
0.5
colors?string[]

Two to eight CSS colors, from the outer streaks to the ones closest to the center. Theme variables such as var(--primary) follow your theme.

Default
["#5b7cff", "#9d6bff", "#ff6ac1"]
core?number

How wide the calm eye in the center is, where the streaks fade out, from 0 (they wind all the way in) to 1 (an eye most of the box wide).

Default
0.4
count?number

About how many streaks a 1280 by 720 box shows, from 100 to 1500. A smaller box shows fewer.

Default
680
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
haze?number

How strongly the soft light around the eye shows, from 0 to 1.

Default
0.5
intensity?number

How bright the streaks are.

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

How long the streaks are, from 0 (dots) to 2. They stretch as they close in whatever the value.

Default
1
lineWidth?number

The thickness of a streak at its head, in pixels, from 0.5 to 3.

Default
1.6
opacity?number

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

Default
1
paused?boolean

Holds the current frame.

Default
false
pull?number

How fast the streaks are drawn in, from 0 (they hang where they are) to 2.

Default
1
quality?number

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

Default
1
seed?number

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

Default
0
speed?number

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

Default
1
tilt?number

How far the disc leans away from you, from 0 (seen from above, a circle) to 0.7 (seen from the side, a wide ellipse).

Default
0.4
time?number

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

twist?number

How tightly the streaks wind around the center, from -3 to 3: 0 falls straight in, and the sign sets which way it turns.

Default
1.2