# Grain Background

> Film grain that takes the flatness off a surface.

Fine noise in the theme ink over a flat colour or a gradient, shifting like projected film. Pure CSS; works over or under content.

- Family: Backgrounds
- Plan: Creative. Included with Creative.
- Requires: React, Tailwind CSS v4 and the motion package
- Page with a live preview: https://galactrex.com/ui/grain-background/
- Licence: https://galactrex.com/ui/license/

## Install

```sh
npx @galactrex/ui login   # once, with an API key from https://galactrex.com/account/
npx @galactrex/ui add grain-background
```

It installs to `components/galactrex/grain-background.tsx`, with the shared motion helpers beside it. First time in a project: `npx @galactrex/ui init` (setup guide: https://galactrex.com/docs/ui-components-setup/).

## Usage

```tsx
import { GrainBackground } from "@/components/galactrex/grain-background";

<section className="relative overflow-hidden">
  <GrainBackground />
  <h1 className="relative">Shot on film</h1>
</section>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `opacity` | `number` | `0.1` | Grain strength, 0 to 1. |
| `fineness` | `number` | `0.85` | 0.5 is coarse, 1.2 is fine. |
| `animate` | `boolean` | `true` | Shift like projected film. |
| `color` | `string` | `var(--gxui-ink)` | Grain colour. |
| `className` | `string` | — | Extra classes for the outer element. |

## Variants

- **Film.** Shifting grain.
- **Print.** `animate={false}` for a still paper texture.

## Accessibility

- Decorative only and aria-hidden; never takes pointer events.
- Keep it below about 0.15 behind body text.

## Motion

- A stepped CSS transform; no canvas.
- Holds still offscreen.
- Reduced motion: still grain.
