Skip to Content
Kokonut UI

BG-07Backgrounds

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.

Install with
no extra packages

PRODither Reveal Hero and more like it are in Kokonut UI Pro

Installation

Halftone Background is a free, open-source React component in the Kokonut UI Backgrounds collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/halftone-background.tsx, so the code is yours to change.

npx shadcn@latest add @kokonutui/halftone-background

Usage

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
numberDefault 9

Distance between dots, in px.

angle
numberDefault 45

Screen angle in degrees; 45 is the classic print angle.

loupe
booleanDefault true

Show a loupe under the cursor that prints at twice the resolution.

Dependencies

NeedsVersionComes from
cn from lib/utils.tsshadcn init
React19Your app
Tailwind CSS4Your app

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