Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Silk Background for React

Slow, broad fields of colour with a satin sheen gliding across them, like light on folded fabric. For React with Base UI, when a launch hero or a sign-up section needs rich colour and calm motion behind its copy.

Framework

Silk fills the box with slow, broad fields of colour and a satin sheen gliding across them. Soft fields of violet, sky and teal on an indigo ground turn once a minute, a warm rose and a violet blob drift over them, and two sets of curved highlight bands glide past each other on top in soft light, like light on folded fabric. Every field eases out to transparent, so nothing ever shows an edge or a line, at any angle or size. It's all CSS gradients moved by transforms, which the browser composites without repainting: no blur, no canvas and no script. It's paler on a light page and deeper on a dark one.

Use it behind a launch hero, a pricing header or a sign-up card. For soft blobs without the sheen, use Mesh Gradient; for sheets of light instead of fabric, Aurora; for flowing bands as distinct strips, Ribbons. Gradient Animation orbits soft colour without folds, Light Waves gives ambient colour washes, and Marble has the same slow drift, in stone.

Preview width

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

import { Silk } from "@/components/ui/silk";
<Silk className="flex min-h-[480px] items-center justify-center">
  <h1 className="text-5xl font-semibold">Launch week</h1>
</Silk>

Silk is a container: your content goes inside it, and the fabric sits behind that content. Give it a size with className; for a whole page, className="fixed inset-0 -z-10" with no children. The fabric is laid over your theme's background by intensity, so it's a pastel satin in light mode and a deep one in dark mode.

Demos

Warm Silk

colors takes up to five CSS colours: the first four make the turning ground and the violet blob, the fifth the warm blob. With fewer, the last one repeats. Here amber, red and magenta.

Preview width

Behind a Card

intensity="subtle" lays the fabric over your background at about a third of its strength, a pale field in light mode and a soft tint in dark mode, so text in your foreground colour reads at body size. speed={0.5} halves the motion.

Preview width

Accessibility

The fabric is decoration: it's hidden from assistive tech and never takes the pointer, so everything you put inside works as usual. With reduced motion everything holds still and you keep the full fabric and sheen as a still image; in forced-colors mode it's hidden. Nothing flashes.

Put copy over it in your foreground colour (text-foreground). At the default medium it stays above 5:1 in light mode and about 4:1 or more in dark mode at the worst moment, enough for headings and short lines; for long body text, use intensity="subtle". strong shows the full colour, so put copy on a plate there, and check again with your own colors.

FAQ

How do I change the colours?

Pass colors with up to five CSS colours. The first is the ground, the second, third and fourth the soft fields that turn over it (the second also colours one blob), and the fifth the warm blob. With fewer, the last one repeats. Colours from one family, with one accent, give the silkiest result.

How do I keep text readable?

Keep the default medium for headings and short lines in your foreground colour. For body text, use intensity="subtle", or put the copy on a plate such as bg-background/80.

Can I turn the sheen off?

Hide the silk-sheen parts with className="**:data-[slot=silk-sheen]:hidden" on the container, and you get plain flowing colour fields.

How fast does it move?

The ground turns once a minute at speed={1}, the blobs drift back and forth over about half a minute and the sheen glides over 40 to 50 seconds. Use 0.5 for a long hero dwell, 2 for something livelier.

Will I see an edge when the fabric turns?

No. The turning ground is a square wider than the box's diagonal, so its edges never come in at any angle, and its colour is soft fields with no stops, so no straight line can form across it, from a phone screen to a wide banner.

Is it expensive?

No script runs. The gradients are drawn once, and while it moves the browser only turns and slides those finished layers on the compositor, the part of the browser that moves layers without repainting them.

What happens with reduced motion?

Everything stops where it starts, and you keep the full fabric and sheen as a still image.

API Reference

Silk

<div> data-slot="silk"

PropType
colors?string[]

Up to five CSS colours for the fabric: the first is the ground, the next three the soft fields that turn over it (the second also colours a blob), the fifth the warm blob; with fewer, the last one repeats. By default indigo, violet, sky, teal and rose.

intensity?"subtle" | "medium" | "strong"

How strongly the colour shows over the background: subtle is a pastel field for body text, strong the full colour. Each is paler on a light surface than on a dark one.

Type
"subtle" | "medium" | "strong"
Default
"medium"
speed?number

How fast the fabric moves: 2 is twice as fast, 0.5 half as fast.

Default
1
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--silk-color-1string

The ground (indigo).

--silk-color-2string

The first field (violet), also a blob.

--silk-color-3string

The second field (sky).

--silk-color-4string

The third field (teal).

--silk-color-5string

The warm blob (rose).

--silk-speedstring

The motion's speed, a multiplier (1).

All 100 backgrounds