Skip to content

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

Pro

Warp Background for Svelte

Streaks of light fly out from a vanishing point, calm at the center. For Svelte with Ark UI, when a hero should feel like it's moving.

On this page10 sections
UI library: Ark UI

Streaks of light fly out from a vanishing point like a jump to hyperspace: short and fine near the point, longer, thicker and brighter toward the edges, in five layers of depth that each move at their own pace. It's a GLSL scene on WebGL2 with no dependency. The middle of the box stays calm, so a headline can sit on the point. On a dark surface the streaks are light with heads that burn toward white; on a light one they're drawn in a deeper ink of the same colors. The vanishing point leans toward the pointer.

Use it behind a hero or a launch section that should feel like it's going somewhere. For closed rings in a tube instead of straight streaks, use Tunnel; for stars that drift and twinkle without the rush, Starfield; for streaks that spiral inward to a center, Vortex. With reduced motion it holds one still frame.

Playground
Warp 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 lang="ts">
import { Warp } from "@/components/ui/warp";
</script>
<Warp class="flex min-h-[32rem] flex-col items-center justify-center">
  <h1 class="text-5xl font-semibold">Served from next door</h1>
</Warp>

Warp 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

Hyperspacethe default lookTry it
<Warp />
Driftthe default lookTry it
<Warp
  density={2}
  glow={0.5}
  length={0.3}
  lineWidth={1.2}
  speed={0.6}
  spread={0.25}
/>
EmberTry it
<Warp
  colors={["#ffe2b8", "#ff9a4d", "#ff4f6e"]}
  haze={0.8}
  length={1.3}
  origin="bottom"
/>
MonoTry it
<Warp
  colors={["var(--foreground)", "var(--muted-foreground)"]}
  depth={1}
  glow={0}
  haze={0}
  lineWidth={1}
/>
NeonTry it
<Warp
  colors={["#22d3ee", "#e879f9"]}
  density={0.8}
  glow={1.6}
  haze={0.2}
  length={1.2}
  lineWidth={2.2}
/>
Rushthe default lookTry it
<Warp
  density={1.5}
  depth={1}
  length={2}
  lineWidth={1}
  speed={1.8}
  spread={0.7}
/>
SpiralTry it
<Warp
  colors={["#5eead4", "#5b9dff", "#c084fc"]}
  curve={0.8}
  length={1.5}
  spread={0.4}
/>

Each preset is a set of props, so copy one and keep tuning. Hyperspace is the default. Drift shortens the streaks to dashes and slows them down for a quiet page, Rush stretches them into long hairlines that leave only the corners busy, Spiral bends them around the point with curve, and Mono takes its two colors from your theme.

Examples

Hero

The copy sits on the vanishing point, where spread keeps the streaks away: they fade in around the headline and reach full strength at the edges. The headline and the line under it use the foreground color; the chip and the second button have a translucent ground of their own.

Preview width

Colors

colors is the range each streak picks its color from: here pale gold, amber and rose on a dark surface, with curve={0.6} bending the streaks into a slow spiral, length={1.4} and density={1.3}.

Preview width

In a card

origin="bottom" puts the vanishing point on the bottom edge, so the streaks fan upward, and fade="bottom" clears that edge for the copy. spread={0.4} lets them start a little closer to the point in a small box.

Preview width

Customization

Every color is a CSS color, so a theme variable works and follows a theme switch: colors={["var(--foreground)", "var(--muted-foreground)"]} draws the streaks in your text colors. Each streak takes one color from the range the list spans, mixed in OKLab, so two distant hues meet in a clean color.

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

<Warp
  class="min-h-[32rem] bg-slate-950"
  colors={["var(--chart-1)", "var(--chart-2)", "var(--chart-3)"]}
  fade="radial"
  spread={0.7}
/>

Performance

It's one WebGL2 canvas and one fragment shader: five layers, and in each a pixel looks up the one streak that can reach it, so the cost doesn't grow with density. There's no noise and no loop beyond the five layers. 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 streaks 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 streak fades in as it leaves the point and travels out of the box.

Put copy on the vanishing point, where the scene is calm, and use the foreground color (text-foreground). Around the point, in the middle third of the box, foreground text keeps more than 12:1 on a light surface and on a dark one at the default settings. Toward the edges a streak's head burns close to white on a dark surface, so keep small text off the outer band, or raise spread.

FAQ

How do I change the colors?

Pass two to eight CSS colors to colors. Each streak picks one color from the range the list spans, so two colors give every tone between them and three or more give a wider mix. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes.

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 streaks are light and their heads burn toward white, and on a light one they're drawn in a deeper, more saturated ink of the same colors, so a thin line still holds on white. Set the surface with a class on the component, such as bg-slate-950.

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. A larger box shows more streaks at the same density, so a full page doesn't look empty.

How do I make it faster or slower?

speed scales time: speed={2} doubles the pace and speed={0.5} halves it. At 1 a streak near the edge of a laptop-sized hero travels about 100 pixels a second, slow enough to sit behind copy. For the look of a jump to light speed, raise speed together with length, as the Rush preset does.

Can I move the vanishing point?

origin places it at the center of the box or in the middle of one of its edges: origin="bottom" fans the streaks upward and origin="left" sends them across. The pointer then leans the point by up to a third of the way toward itself. Turn that off with interactive={false}.

Will it slow my page down?

It's a light shader: five streak lookups a pixel, no noise, on the GPU, 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; thin streaks soften slightly at that scale.

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 streaks and stops, and the pointer no longer moves the vanishing point. The frame is the same one every time, so the page looks the same on each visit. On a phone the scene animates as usual, but touch never steers it, so scrolling isn't disturbed.

API Reference

Warp

data-slot="warp"

PropType
colors?string[]

Two to eight CSS colors; each streak takes one from the range they span. Theme variables such as var(--foreground) follow your theme.

Default
["#b9d2ff", "#5b9dff", "#9d7bff"]
curve?number

How far the streaks bend into a spiral around the vanishing point, from -1 to 1. At 0 they run straight; the sign sets the way they turn.

Default
0
density?number

How many streaks are in flight, from 0.3 to 2. A larger box shows more of them at the same value.

Default
1
depth?number

How different the far streaks are from the near ones, from 0 (all alike) to 1 (far ones fine, slow and dim, near ones thick and fast).

Default
0.8
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

How much soft light surrounds each streak, from 0 to 2.

Default
1
grain?number

Film grain over the scene, from 0 to 1.

Default
0
haze?number

How strong the soft light at the vanishing point is, 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.3 (short dashes) to 2.

Default
1
lineWidth?number

The thickness of a near streak at its head, in pixels, from 0.5 to 3. Far streaks are thinner.

Default
1.5
opacity?number

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

Default
1
origin?"center" | "top" | "bottom" | "left" | "right"

Where the vanishing point sits: the center of the box, or the middle of one of its edges.

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

Another layout of the same look.

Default
0
speed?number

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

Default
1
spread?number

How wide the calm area around the vanishing point is, from 0 (streaks start at the point) to 1 (they show only near the edges).

Default
0.5
time?number

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