Silk Cloth
Installation
npx shadcn@latest add https://uibrik.com/r/silk-cloth.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/silk-cloth/silk-cloth.tsx"use client"; import { ShaderSurface, type ShaderBackgroundProps } from "../_shader-background/ShaderSurface"; // A sheet of satin, rippling as if in a light breeze. // // The cloth is a height field of long folds: a broad wave and a finer one running across the // threads, bent by slow noise so the folds wander, merge and split the way draped fabric does. Here // and there a soft crease crosses them, where the cloth bunches up. // // It's lit like a studio shot: a key light from the top left gives the folds their body, and a dim // fill from the opposite side keeps the shadow side from going dead. What makes it satin is the // sheen: a tight highlight that stretches along the threads, so every crest carries a long bright // streak, wrapped in a broader glow. Slopes turned away from the viewer catch a soft rim of light, // the valleys fall into a coloured shadow (satin lets a little light through), and a faint weave runs // through the highlights. // // The shading runs through the palette, from the deepest shadow to the brightest sheen. const SHADER = /* glsl */ ` uniform float u_angle; // direction of the folds, degrees uniform float u_folds; // how many folds fit across the frame uniform float u_depth; // how deep the folds are uniform float u_flow; // how much the folds wander uniform float u_creases; // soft creases across the folds
Adds the files to
components/uibrik/silk-cloth. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/silk-cloth.Props
SilkCloth- colors
- Type string[]
- ["#0f0308","#3d0a20","#8a1d44","#d4607f","#ffd9e3"]
- From the deepest shadow to the brightest sheen, blended in OKLCH; 2 to 6 colours.
- angle
- Type number
- -25
- Direction of the folds.
- folds
- Type number
- 0.8
- How many folds fit across the frame.
- depth
- Type number
- 1
- How deep the folds are.
- flow
- Type number
- 1
- How much the folds wander.
- creases
- Type number
- 0.6
- Soft creases across the folds, where the cloth bunches up.
- sheen
- Type number
- 1
- Strength of the sheen along the threads.
- gloss
- Type number
- 0.4
- How tight the sheen is; higher is glossier.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- grain
- Type number
- 0.075
- Film grain strength.
- seed
- Type number
- 0
- Shifts the composition, so two backgrounds with the same settings still differ.
- animate
- Type boolean
- true
- Move on its own. Off draws one still frame.
- children
- Type ReactNode
- –
- Content shown on top of the background.
- className
- Type string
- –
- Classes for the box; it fills whatever size you give it.