Skip to content

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

Pro

Silk Background for Vue

Folds of satin drift under a light, with a two-tone sheen. For Vue with Ark UI, when a hero or a product card should feel like cloth.

On this page10 sections
UI library: Ark UI

Silk fills its box with one length of satin: long folds that wander down the box, a finer set riding on them and a few wrinkles, lit from the side so the slopes that face the light catch a sheen. It's a GLSL scene on WebGL2: a height field, its slope taken from three samples, and a light. The sheen turns toward a second color, as shot silk does. On a light surface the cloth is pale with the color in its folds, on a dark one deep with the color in its sheen. The light leans toward the pointer, and a press sends a ripple through the cloth.

Use it behind a hero, a product card or a pricing header when one color with depth suits the page better than a palette. For bands of several colors that flow, use Gradient; for color in soft areas, Mesh Gradient; for a polished metal surface instead of cloth, Mercury. With reduced motion it draws one still frame.

Playground
Silk 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 { Silk } from "@/components/ui/silk";
</script>
<template>
  <Silk class="flex min-h-[32rem] flex-col items-center justify-center gap-4">
    <h1 class="text-5xl font-semibold">Bedding you'll want to stay in</h1>
    <p class="text-foreground/80">Washed mulberry silk, cut and sewn to order.</p>
  </Silk>
</template>

Silk is a container: what you put inside sits on top of the cloth, 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

Satinthe default lookTry it
<Silk />
CurtainTry it
<Silk
  :angle="0"
  color="#2563eb"
  :folds="1.4"
  :scale="1.4"
  sheenColor="#93c5fd"
  :softness="0.8"
/>
JadeTry it
<Silk
  color="#0d9488"
  :detail="0.8"
  :scale="1.6"
  sheenColor="#a7f3d0"
  :softness="0.3"
/>
LinenTry it
<Silk
  color="#94a3b8"
  :detail="1"
  :folds="0.6"
  :scale="1.8"
  :sheen="0.3"
  sheenColor="#e2e8f0"
  :softness="1"
/>
MidnightTry it
<Silk
  color="#312e81"
  :scale="0.7"
  :sheen="1.6"
  sheenColor="#818cf8"
  :softness="0.15"
/>
PearlTry it
<Silk
  color="var(--muted-foreground)"
  sheenColor="var(--foreground)"
  :softness="0.8"
/>
RubyTry it
<Silk color="#e11d48" :intensity="1.5" sheenColor="#fbbf24" />

satin is the default: violet cloth with a rose sheen. pearl takes both colors from the theme, var(--muted-foreground) and var(--foreground), so it's white satin on a light page and black satin on a dark one. curtain sets angle to 0, which hangs the folds straight down. linen drops sheen to 0.3 and raises detail to 1 for a matte, wrinkled cloth. ruby is the one preset that sets intensity above 1, so its red and gold show at their own depth: check the contrast of copy you put on it.

Examples

Hero

A badge, a headline, one line of copy and two links, centered over the default look with no props. The cloth is held to a tone copy can sit on, pale on a light surface and deep on a dark one, so the headline in text-foreground reads in both themes; the secondary link gets bg-background/60 backdrop-blur.

Preview width

Colors

color is the cloth and sheenColor is what its sheen turns toward: here ruby with a gold sheen. intensity={1.5} lets go of the tone hold, so the red is as deep as written on a light page and the gold as bright as written on a dark one.

Preview width

Card

Jade cloth in a 384 px card. scale={1.6} packs narrower folds into the small box, detail={0.8} adds wrinkles and softness={0.3} tightens the sheen into a gloss. The copy sits at the bottom in the foreground color.

Preview width

Customization

color and sheenColor take any CSS color: hex, oklch(), color-mix() or a theme variable such as var(--primary), read again when the theme changes. Pass the same color to both for a plain weave. angle tilts the folds, and lightAngle is measured from the folds, not from the box, so the relief stays the same when you turn them: 90 lights them from the side, 0 runs the light along them. folds sets their depth, sheen how much light they catch and softness how wide that light spreads.

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 the cloth to its deep tones. fade fades one edge into the surface, grain adds film grain, which reads as a weave, and opacity thins the whole scene.

<Silk
  className="min-h-svh"
  color="var(--muted-foreground)"
  fade="bottom"
  grain={0.15}
  sheenColor="var(--foreground)"
/>

Performance

It's one WebGL2 canvas and a shared runtime with no dependency. Each pixel reads the height of the cloth three times to get its slope, and each height is four samples of simplex noise and three sines, so twelve noise samples a pixel, with no ray march and no simulation. 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, 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 5 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.5:1 on a light surface and 5.6:1 on a dark one. The hold works on lightness, so it applies to your own colors too: the cloth is never deeper than 0.66 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. A press ripples the cloth once and fades in about two seconds; nothing flashes.

FAQ

How do I change the color of the cloth?

Pass color for the cloth and sheenColor for what its sheen turns toward, such as color="#0d9488" sheenColor="#a7f3d0". Any CSS color works, theme variables included. A sheenColor close to the cloth's own hue reads as plain satin; one far from it, such as gold on red, reads as shot silk woven from two threads.

Why is the cloth paler or deeper than the color I passed?

At intensity={1} the scene keeps a tone copy can sit on. On a light surface your color sits in the folds and the light bleaches it toward white; on a dark one it sits in the sheen and the folds fall toward black. Raise intensity toward 2 to show the color at its own depth, and check your text contrast when you do.

How do I change the direction of the folds?

angle tilts them, in degrees: 0 hangs them straight down like a curtain, 90 lays them across the box, and the default 35 runs them from the lower left to the upper right. The light turns with the folds, because lightAngle is measured from them, so you don't have to retune it.

Does it work in light and dark mode?

Yes, with no props. The scene reads the surface behind it and picks the pale cloth or the deep one. The surface is the root's background, so bg-slate-950 or your own color works the same way. The pearl preset goes further and takes its two colors from the theme too.

What does the pointer do, and can I turn it off?

The light leans toward the pointer, so the sheen slides across the folds as it moves, and a press sends one ring through the cloth from where you pressed. Presses on links, buttons and fields over the cloth don't ripple it, and touch never moves the light. interactive={false} turns both off.

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 costs twelve noise samples a pixel, which is moderate, and nothing while it's off screen or the tab is hidden. If a device can't keep up, it renders fewer pixels by itself; quality={0.75} does that up front for a phone-first page. 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.

What happens with reduced motion?

The scene draws one frame and holds it: the same folds every time, with no drift, and the light no longer follows the pointer. paused does the same for everyone, and speed={0} holds whichever frame it's on.

API Reference

Silk

data-slot="silk"

PropType
angle?number

The tilt of the folds, in degrees: 0 hangs them straight down like a curtain, 90 lays them across the box.

Default
35
color?string

The color of the cloth, as any CSS color. A theme variable such as var(--muted-foreground) follows your theme.

Default
"#6d4aff"
detail?number

How many fine wrinkles the cloth carries on top of its folds, from 0 (smooth) to 1.

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.

folds?number

How deep the folds are, from 0 (a flat sheet) 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 the cloth is held to a tone copy reads on: pale on a light surface, deep on a dark one. Toward 2 that hold lets go and the color 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
lightAngle?number

The angle between the light and the folds, in degrees: 90 lights them from the side, where they show the most relief, 0 runs the light along them. Negative values light them from the other side.

Default
75
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
scale?number

The size of the folds: higher packs more, narrower folds into the box.

Default
1
seed?number

Another layout of the folds, from 0 to 20.

Default
0
sheen?number

How much sheen the folds catch, from 0 (matte, like cotton) to 2.

Default
1
sheenColor?string

The color the sheen turns toward, as on shot silk woven from two threads. Pass the cloth's own color for a plain weave.

Default
"#ff7ac8"
softness?number

How wide the sheen spreads, from 0 (a tight gloss, like wet satin) to 1 (a broad glow, like brushed silk).

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