Silk
Satin folds that drift and catch the light. Use case: Luxury landing.
Backgrounds · React · Tailwind CSS v4 · MIT · TypeScript
Install
npx shadcn@latest add https://www.kavynui.com/r/shader-silk.json
Or register the library once (npx shadcn@latest registry add @kavynui=https://www.kavynui.com/r/{name}.json) and run npx shadcn@latest add @kavynui/shader-silk. Registry item: /r/shader-silk.json.
Use
import ShaderSilk from '@/components/kavyn/shader-silk'
export default function Page() {
return <ShaderSilk />
}
Files: components/kavyn/shader-silk.tsx, components/kavyn/shader-bg.tsx. Packages: react.
Source: shader-silk.tsx
'use client'
import ShaderBackground, { type ShaderBackgroundProps } from './shader-bg'
const FRAG = `
void main(){
vec2 c=centered();vec2 p=c*uScale;vec2 m=pointer()*uScale;float t=uTime*.22;
p+=uMouse.w*.14*(p-m)*exp(-2.5*length(p-m));
p.y+=.22*sin(p.x*1.4+t)+.1*sin(p.x*3.1-t*1.4);
float n=fbm(vec2(p.x*.7+t*.25,p.y*2.4-t*.1));
float fold=sin(p.y*11.+n*8.+p.x*1.6+t);
float sheen=pow(.5+.5*fold,2.2);
float thread=pow(.5+.5*sin(p.y*27.+n*17.+t*1.3),6.);
float shade=.5+.5*sin(p.y*3.6+n*3.2-t*.5);
float lit=.35+.65*shade;
float v=.03+.12*shade+.62*sheen*lit+.18*thread*lit;
paint(v*smoothstep(1.5,.15,length(c)),sheen);
}
`
// Satin folds that drift and catch the light. The cloth gives a little where the pointer rests.
// Ink and paper come from your theme (--tx on --bg), so it works in light and dark. Pass `color` to tint it.
export default function ShaderSilk({ color = '', color2 = '', speed = 1, intensity = 1, scale = 1, interactive = true, allowSoftware = true, className = '', style, children }: ShaderBackgroundProps) {
return (
<ShaderBackground frag={FRAG} color={color} color2={color2} speed={speed} intensity={intensity} scale={scale} interactive={interactive} allowSoftware={allowSoftware} className={className} style={style}>
{children}
</ShaderBackground>
)
}
More in Backgrounds
- Liquid Chrome - Slow liquid-metal reflections that part around the pointer. For: AI product hero.
- Horizon - The lit edge of a planet rising under your headline. For: Waitlist page.
- Light Rays - Shafts of light falling from above, with dust in the beams. For: Pricing page header.
- Polar Veil - Aurora curtains with fine rays over a starfield. For: Sign-up screen.
- Ink Current - Ink folding through water, bending away from the pointer. For: Launch page.
- Pool Light - Light dancing on a pool floor, gathering under the pointer. For: Travel landing.
- Strands - A bundle of fine lines twisting like fibre in a current. For: Audio or data product.
- Wave Lattice - A dot grid carrying waves, rippling out from the pointer. For: Dev tool hero.