# Halftone Background

Any image, or a lit sphere, printed as a halftone dot screen, with a loupe that looks closer under the cursor, built with React and canvas.

## Installation

Halftone Background is a free, open-source React component in the Kokonut UI [Backgrounds collection](/content/docs/backgrounds/index.html). Add it with the shadcn CLI, which copies the source into `components/kokonutui/halftone-background.tsx`, so the code is yours to change.

```bash
npx shadcn@latest add @kokonutui/halftone-background
```

## Usage

```javascript
import HalftoneBackground from "@/components/kokonutui/halftone-background";

export default function Example() {
  return <HalftoneBackground />;
}
```

## Props

- `className`: `string` – Extra classes for the root element.
- `children`: `ReactNode` – Content shown over the dots. Pass `null` for a bare background.
- `src`: `string` – An image to print as dots. It must be same-origin or served with CORS headers. Without one, a lit sphere is drawn.
- `cell`: `number` Default `9` – Distance between dots, in px.
- `angle`: `number` Default `45` – Screen angle in degrees; 45 is the classic print angle.
- `loupe`: `boolean` Default `true` – Show a loupe under the cursor that prints at twice the resolution.

## Dependencies

| Needs                          | Version | Comes from         |
| ------------------------------ | ------- | ------------------ |
| `cn` from `lib/utils.ts`      |         | shadcn init        |
| React                          | `19`   | Your app           |
| Tailwind CSS                  | `4`    | Your app           |

No provider, font or global CSS to set up: the file works as soon as it lands.
