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.
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-backgroundUsage
import HalftoneBackground from "@/components/kokonutui/halftone-background";
export default function Example() {
return <HalftoneBackground />;
}Props
classNamestringExtra classes for the root element.
childrenReactNodeContent shown over the dots. Pass null for a bare background.
srcstringAn image to print as dots. It must be same-origin or served with CORS headers. Without one, a lit sphere is drawn.
cellnumberDefault 9Distance between dots, in px.
anglenumberDefault 45Screen angle in degrees; 45 is the classic print angle.
loupebooleanDefault trueShow 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.