Skip to Content
zjkm-ui
Components

Film Grain

A film grain overlay.

Golden hour

Props
0.12
0.8s
<FilmGrain>
  <Hero />
</FilmGrain>

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/film-grain.json
import { 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

PropTypeDefaultDescription
childrenReactNodeThe content under the grain.
opacitynumber0.12Strength of the grain, from 0 to 1.
speednumber0.8Seconds per flicker cycle.
classNamestringClasses for the wrapper.

With reduced motion, the grain stays still.

On this page