shadcn.io is an independent project built on shadcn/ui
Portal Background for Svelte
Warped rings of light stacked in depth, breathing like a gateway. For Svelte with Ark UI, when a launch page needs a way in.
On this page10 sections
A gateway of warped concentric rings, stacked in depth: the inner ones bunch up, thin out and dim as they recede toward a soft light at the far end, and the outermost is the bright rim. The rings breathe in and out one after another, and their bulges travel slowly around them. It's a GLSL scene on WebGL2 with no dependency. On a dark surface the rings are light; on a light one they're painted in the colors themselves. The gateway leans toward the pointer.
Use it behind a launch or waitlist hero, a game or event intro, or the top of a card. For rings of light rushing toward you down a tunnel, use Tunnel; for one sphere of swirling color, Orb; for flat rings that pulse outward and fade, Ripple. With reduced motion it holds one still frame.


Installation
Usage
<script lang="ts">
import { Portal } from "@/components/ui/portal";
</script>
<Portal class="flex min-h-[32rem] flex-col items-center justify-center">
<h1 class="text-5xl font-semibold">Step into the next build</h1>
</Portal>
Portal is a container: whatever you put inside sits on top of the rings, in normal flow. It fills its own box, so give it a height or content. The gateway is sized by the box: size is the rim's radius as a share of the shorter side, and a wide or tall box shows it up to 1.6 times larger, cropped by its near edges. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".
Presets
<Portal /><Portal origin="bottom" rings={6} size={0.7} /><Portal
colors={["#be123c", "#f43f5e", "#fb923c"]}
rings={8}
warp={1.4}
/><Portal depth={0} glow={1.6} rings={4} thickness={4} warp={0.3} /><Portal
colors={["var(--muted-foreground)", "var(--foreground)"]}
glow={0.4}
thickness={1.5}
/><Portal
colors={["#22d3ee", "#a855f7", "#f472b6"]}
rings={9}
spin={2}
warp={2}
/><Portal depth={1} rings={12} size={0.5} thickness={2} warp={0.4} />Each preset is a set of props, so copy one and keep tuning. Gateway is the default. Tunnel is twelve nearly round rings at full depth, Arch centers six rings on the bottom edge so half of the gateway rises from it, Halo is four thick flat rings with more glow, Rift bends nine rings twice as far in cyan, purple and pink, and Mono takes its two colors from your theme.
Examples
Hero
The copy sits in the middle of the gateway, where the rings are far away: thin, dim and close together. The bright rim passes outside the headline. No props are set.
Ember
colors runs from the far end to the rim: here deep rose, rose and orange on a dark surface, with eight rings and warp={1.4}, so they bend a little further from circles.
In a card
origin="top" centers the gateway on the middle of the top edge, so its lower half hangs into the card and the text sits under the rim. size={0.62} widens it past the card's sides, with six rings.
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 first is the far end and the last the rim, with the rest spread between and 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 scene adapts: on a dark surface the rings are light and their cores burn toward white, on a light one they're painted, a pale color such as cyan a tone deeper so a thin ring holds on white. depth={0} flattens the gateway into evenly spaced rings, spin={0} leaves only the breathing, fade masks an edge, opacity turns the whole effect down, and grain adds film grain.
<Portal
class="min-h-[32rem] bg-slate-950"
colors={["var(--chart-4)", "var(--chart-2)", "var(--chart-1)"]}
depth={1}
grain={0.2}
rings={9}
/>
Performance
It's one WebGL2 canvas and one fragment shader with no dependency. For each pixel it takes one arctangent, loops over the rings, 12 at most, with five sines each, and mixes one color at the end: there is no noise and no texture. 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 gateway is decoration: the canvas is hidden from assistive tech and lets every click through to your content. With reduced motion it draws one still frame and ignores the pointer and presses. Nothing flashes: a breath takes about 12 seconds.
Use the foreground color (text-foreground) for every line on top, and keep copy in the middle of the gateway, where the rings are dim. On a light surface the lowest contrast we measured between foreground text and any pixel of the default scene is 5.7:1. On a dark surface the rings are bright: light text keeps 4.5:1 over all but the cores of the outer rings, about 4% of the box and under 2% of its middle. Lower intensity or thickness, or raise depth, if a ring behind small text bothers you.
FAQ
How do I change the colors?
Pass two to eight CSS colors to colors. The first is the far end of the gateway and the last is its rim, 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.
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 rings add light and their cores burn toward white, and on a light one each ring is painted in its own color, a pale one a tone deeper, over a soft tint of the same palette. Set the surface with a class on the component, such as bg-slate-950.
How do I make the rings rounder, or more warped?
warp is how far the rings bend away from circles: 0 is perfect circles, 1 the default, 2 the most. seed picks another shape for the same amount of warp, spin sets how fast the bulges travel around the rings (negative turns them the other way), and amplitude how far the rings swell as they breathe.
What does depth change?
At depth={0} the rings are evenly spaced, equally thick and equally bright, like a target. As it rises to 1 the inner rings move closer together, get thinner, softer and dimmer, so the gateway reads as a tunnel seen from its mouth, and the far end leans further toward the pointer than the rim does.
How do I put it behind the whole page?
Render it empty with className="fixed inset-0 -z-10". The gateway is sized by the viewport, so it fills a phone and a desktop the same way; on a wide screen its rim is cropped at the top and bottom. origin="bottom" or origin="top" shows half of it as an arch. It still follows the pointer there, since it listens on the window.
Can I turn off the pointer effect?
Yes: interactive={false}. By default the gateway leans toward the pointer, by about a fifth of the pointer's distance at the far end and a twentieth at the rim, which gives it depth. A press sends a pulse of light from the rim to the far end. Touch never moves it, so scrolling on a phone isn't disturbed.
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.
API Reference
Portal
data-slot="portal"
amplitude?number
How far the rings swell and shrink as the gateway breathes, from 0 to 2.
- Default
1
colors?string[]
Two to eight CSS colors, from the far end of the gateway to its rim.
Theme variables such as var(--primary) follow your theme.
- Default
["#8b5cf6", "#4f7dff", "#22d3ee"]
depth?number
How deep the gateway looks, from 0 (flat, evenly spaced rings) to 1 (a tunnel: the inner rings bunch up, thin out and dim as they recede).
- Default
0.75
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 the rings and fills the far end, from 0 to 2.
- Default
1
grain?number
Film grain over the scene, from 0 to 1.
- Default
0
intensity?number
How bright the rings 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
opacity?number
How strongly the scene shows over the surface, from 0 to 1.
- Default
1
origin?"center" | "top" | "bottom" | "left" | "right"
Where the gateway is centered: the center of the box, or the middle of one of its edges, where half of it shows as an arch.
- 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
rings?number
How many rings the gateway has, from 2 to 12.
- Default
7
seed?number
Another shape of the same look: where the rings bulge and pinch.
- Default
0
size?number
The radius of the outermost ring, from 0.15 to 0.9, as a share of the box's shorter side: 0.5 touches the edges of a square box. A wide or tall box shows the gateway up to 1.6 times larger, cropped by its near edges.
- Default
0.44
speed?number
Animation speed: 1 is normal, 0 holds the frame.
- Default
1
spin?number
How fast the bulges travel around the rings, from -2 to 2. Negative turns them the other way; 0 leaves only the breathing.
- Default
1
thickness?number
The thickness of the outermost ring, in pixels, from 1 to 8. The rings behind it are thinner.
- Default
2.5
time?number
A fixed moment, in seconds: draws it and doesn't animate.
warp?number
How far the rings bend away from circles, from 0 to 2.
- Default
1











