Components
Film Grain
A film grain overlay.
Golden hour
<FilmGrain>
<Hero />
</FilmGrain>Installation
npx shadcn@latest add https://ui.zjkm.tech/r/film-grain.jsonimport { FilmGrain } from "@/components/film-grain"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Lays a flickering film grain over whatever you wrap. The grain is a tiny tiled SVG that moves around, so it costs almost nothing to draw. Clicks pass straight through it.
import { FilmGrain } from "@/components/film-grain";
export function Hero() {
return (
<FilmGrain opacity={0.15}>
<img src="/hero.jpg" alt="Harbour at dusk" />
</FilmGrain>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | The content under the grain. | |
opacity | number | 0.12 | Strength of the grain, from 0 to 1. |
speed | number | 0.8 | Seconds per flicker cycle. |
className | string | Classes for the wrapper. |
With reduced motion, the grain stays still.