# Dither Reveal

An image that resolves from dithered palette tones into the photo.

Source: https://gradients.sh/docs/pro/dither-reveal

## Installation

```bash
npx gradients.sh add dither-reveal
```

Pro: this needs a Pro account. The first run on a computer prints a login link for the user to approve, then you run it again. Details: https://gradients.sh/docs/pro.md.

## Usage

```tsx
import { DitherReveal } from "@/components/dither-reveal";

<DitherReveal src="/photo.jpg" alt="" className="aspect-[4/3]" />;
```

## Props

| Prop                           | Type                                             | Default             | Description                                                                                                                                                      |
| ------------------------------ | ------------------------------------------------ | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `src`                          | `string`                                         | required            | The image. Images on another origin need CORS headers and `crossOrigin`.                                                                                         |
| `alt`                          | `string`                                         | required            | Alternative text, passed to the `<img>`. Use `""` when a nearby heading already describes it.                                                                    |
| `trigger`                      | `"hover" \| "visible" \| "manual"`               | `"hover"`           | `"hover"` reveals on hover and focus within; `"visible"` reveals once when half of it scrolls into view; `"manual"` follows `revealed`.                          |
| `revealed`                     | `boolean`                                        | `false`             | With `trigger="manual"`, shows the photo when true.                                                                                                              |
| `palette`                      | `"ultramarine" \| "ember" \| "mono" \| string[]` | `"ultramarine"`     | A curated ramp, or your own 2 to 6 CSS colours from faint to hot (`var(--x)` included). Curated ramps switch between a light and a dark version with your theme. |
| `base`                         | `string`                                         | near-black or paper | Colour of the darkest cells.                                                                                                                                     |
| `cell`                         | `number`                                         | `4`                 | Size of one dither cell in CSS pixels.                                                                                                                           |
| `duration`                     | `number`                                         | `900`               | Milliseconds for the dissolve.                                                                                                                                   |
| `scheme`                       | `"light" \| "dark"`                              | follows the page    | Forces a colour scheme. By default it reads a `dark` or `light` class (or `data-theme`) on `<html>`, then the system setting.                                    |
| `crossOrigin`                  | `"anonymous" \| "use-credentials"`               | none                | Passed to the `<img>`.                                                                                                                                           |
| `children`                     | `ReactNode`                                      | none                | Drawn above the image, for captions and badges.                                                                                                                  |
| `className`, other `div` props |                                                  |                     | The outer box. Give it a size, such as `aspect-[4/3]`.                                                                                                           |
