Updated
Grain Gradient
Customize
Colors
Scale1.00
Warp1.00
Sheen0.60
Angle30°
Sweep0.70
Vignette0.50
Speed1.0
Grain0.080
Grain size1.0px
Seed0
Twist1.00
Installation
npx shadcn@latest add https://uibrik.com/r/grain-gradient.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/grain-gradient/grain-gradient.tsx"use client"; import type { CSSProperties, ReactNode } from "react"; import { ShaderSurface } from "../_shader-background/ShaderSurface"; // Colour that folds like silk, finished with film grain. Noise feeds noise twice over (domain // warping, after Inigo Quilez), so the bands curl into each other instead of just drifting. The // result runs along the colour list, with a soft sheen on the folds and a gentle vignette. The // pointer twists the silk around itself, trailing a little behind like fabric being drawn. const SHADER = /* glsl */ ` uniform float u_scale; // size of the shapes uniform float u_warp; // how much the flow folds into itself uniform float u_sheen; // light on the folds uniform float u_angle; // direction the colours run, degrees uniform float u_sweep; // how far apart the first and last colours sit uniform float u_vignette; // darkening toward the corners uniform float u_twist; // how strongly the pointer twists the silk float fbm(vec3 p) { float sum = 0.0; float amp = 0.5; for (int i = 0; i < 3; i++) { sum += amp * snoise(p); p = p * 1.9 + vec3(1.7, 9.2, 0.3);
Adds the files to
components/uibrik/grain-gradient. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/grain-gradient.Too large to paste whole, so Copy prompt gives a short prompt that installs it with the CLI. Download the full prompt to attach it instead.
Usage
import { GrainGradient } from "@/components/uibrik/grain-gradient/grain-gradient";const colors = ["#07142e", "#123a7c", "#2b6bd6", "#7db4f2", "#dcebfc"];<GrainGradient colors={colors} scale={1} warp={1} sheen={0.6} angle={30} sweep={0.7} vignette={0.5} speed={1} grain={0.08} grainSize={1} seed={0} interactive twist={1} animate> …</GrainGradient>Where to use Grain Gradient
Warm hero backgrounds
Colour folding like silk with film grain adds warmth behind a headline.
Pairs with Mesh Gradient
Campaign pages
A slow shifting gradient in brand shades gives seasonal pages a premium finish.
Music and fashion sites
Grain gives the gradient a printed, analogue texture suited to creative brands.
Pairs with Oil Slick
Props
GrainGradient- colors
- Type string[]
- ["#07142e","#123a7c","#2b6bd6","#7db4f2","#dcebfc"]
- Hex colours, 2 to 6, laid out from first to last across the flow.
- scale
- Type number
- 1
- Size of the shapes; larger is calmer.
- warp
- Type number
- 1
- How much the flow folds into itself.
- sheen
- Type number
- 0.6
- Soft light on the folds.
- angle
- Type number
- 30
- Direction the colours run; 0 is left to right.
- sweep
- Type number
- 0.7
- How far apart the first and last colours sit; 0 mixes them all evenly.
- vignette
- Type number
- 0.5
- Darkening toward the corners.
- speed
- Type number
- 1
- Animation speed; 1 is the designed pace.
- grain
- Type number
- 0.08
- Film grain strength.
- grainSize
- Type number
- 1
- Size of a grain speck.
- seed
- Type number
- 0
- Shifts the composition, so two backgrounds with the same settings still differ.
- interactive
- Type boolean
- true
- Twist the silk with the pointer.
- twist
- Type number
- 1
- How strongly the pointer twists the silk.
- 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.