Liquid Chrome
Slow liquid-metal reflections that part around the pointer. Use case: AI product hero.
Backgrounds · React · Tailwind CSS v4 · MIT · TypeScript
Install
npx shadcn@latest add https://www.kavynui.com/r/shader-chrome.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-chrome. Registry item: /r/shader-chrome.json.
Use
import ShaderChrome from '@/components/kavyn/shader-chrome'
export default function Page() {
return <ShaderChrome />
}
Files: components/kavyn/shader-chrome.tsx, components/kavyn/shader-bg.tsx. Packages: react.
Source: shader-chrome.tsx
'use client'
import ShaderBackground, { type ShaderBackgroundProps } from './shader-bg'
const FRAG = `
void main(){
vec2 p=centered()*uScale*2.1;vec2 m=pointer()*uScale*2.1;float t=uTime*.18;
vec2 away=p-m;p+=uMouse.w*.4*away/(length(away)+.2)*exp(-1.6*length(away));
for(int i=1;i<6;i++){float f=float(i);
p.x+=.5/f*sin(f*1.6*p.y+t+f*.7);
p.y+=.5/f*cos(f*1.6*p.x+t*1.2+f*1.9);}
float w=.5+.5*sin(p.x*1.8+p.y*1.4);
float band=smoothstep(.15,.85,w);
float spec=pow(w,9.);
float edge=pow(.5+.5*sin(p.x*3.1-p.y*2.3+1.3),7.);
paint(.03+.2*band*band+.42*spec+.2*edge,spec);
}
`
// Liquid metal: slow reflections that fold over each other and part around the pointer.
// 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 ShaderChrome({ 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
- Silk - Satin folds that drift and catch the light. For: Luxury landing.
- 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.