nook
Browse the docs

Components

Image effect

Native

Eleven ways to treat an image, from frosted square glass to pixels, dithering and characters.

See the prompt

A new perspective

Color study, 2026
Form / Field: a pink sun over green geometric hills, with a pale yellow path and a blue sky.

Installation

npx nook-ui@latest add image-effect

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Image effect" component to this project, exactly as Nook ships it.

Eleven ways to treat an image, from frosted square glass to pixels, dithering and characters.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add image-effect`. It writes `components/ui/image-effect.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/image-effect.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
"use client";

import * as React from "react";
import { ImageEffect, ImageEffectPicker, type ImageEffectName } from "@/components/ui/image-effect";
import { scene } from "./scene";

export default function ImageEffectDefault() {
  const [effect, setEffect] = React.useState<ImageEffectName>("glass");
  return <div className="grid w-full gap-4">
    <div className="flex items-baseline justify-between gap-4"><h3 className="text-base font-medium">A new perspective</h3><span className="text-xs text-muted-foreground">Color study, 2026</span></div>
    <ImageEffect src={scene} alt="Form / Field: a pink sun over green geometric hills, with a pale yellow path and a blue sky." effect={effect} tileSize={effect === "glass" ? 48 : effect === "ascii" ? 6 : effect === "bit" ? 2 : 12} />
    <ImageEffectPicker value={effect} onValueChange={setEffect} />
  </div>;
}
```

API
- `ImageEffect`: An image with CSS, SVG or canvas processing. Uses a 4:3 frame by default; change its aspect ratio with className.
  - `src / alt` (`string`): The source and required description of the image.
  - `effect` (`ImageEffectName`, default none): Which image treatment to apply.
  - `amount` (`number`, default 0.75): Effect intensity, clamped to zero through one.
  - `tileSize` (`number`): Square glass tile, pixel block or character cell size in CSS pixels.
  - `fit` (`"cover" | "contain"`, default cover): Crop to fill, or keep the whole image in the frame.
  - `crossOrigin` (`"anonymous" | "use-credentials"`): Optional image CORS mode. The source server must allow pixel access.
  - `...props` (`React.HTMLAttributes<HTMLDivElement>`): Everything the native element accepts, such as `id`, `aria-*` and event handlers.
- `ImageEffectPicker`: A single-choice ToggleGroup containing every effect. IMAGE_EFFECTS exports the same choices for custom controls.
  - `value / defaultValue` (`ImageEffectName`, default none): Controlled or initial selection.
  - `onValueChange` (`(effect: ImageEffectName) => void`): Receives the selected effect.
- Variant `effect`: none, blur, grayscale, monochrome, high-contrast, soft, glass, pixelate, bit, ascii, water (default none)

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: The original image always carries the required alt text. Canvas and ASCII layers are decorative. Unreadable cross-origin pixels fall back to the image. Water becomes static with reduced motion. The effect picker reuses ToggleGroup keyboard navigation.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

"use client";

import * as React from "react";
import { ImageEffect, ImageEffectPicker, type ImageEffectName } from "@/components/ui/image-effect";
import { scene } from "./scene";

export default function ImageEffectDefault() {
  const [effect, setEffect] = React.useState<ImageEffectName>("glass");
  return <div className="grid w-full gap-4">
    <div className="flex items-baseline justify-between gap-4"><h3 className="text-base font-medium">A new perspective</h3><span className="text-xs text-muted-foreground">Color study, 2026</span></div>
    <ImageEffect src={scene} alt="Form / Field: a pink sun over green geometric hills, with a pale yellow path and a blue sky." effect={effect} tileSize={effect === "glass" ? 48 : effect === "ascii" ? 6 : effect === "bit" ? 2 : 12} />
    <ImageEffectPicker value={effect} onValueChange={setEffect} />
  </div>;
}

Examples

Ten ways to see it

A geometric landscape shown with the blur effect.
blur
A geometric landscape shown with the grayscale effect.
grayscale
A geometric landscape shown with the monochrome effect.
monochrome
A geometric landscape shown with the high-contrast effect.
high contrast
A geometric landscape shown with the soft effect.
soft
A geometric landscape shown with the glass effect.
glass
A geometric landscape shown with the pixelate effect.
pixelate
A geometric landscape shown with the bit effect.
bit
A geometric landscape shown with the ascii effect.
ascii
A geometric landscape shown with the water effect.
water

Variants

Defined in one place with cva, at the top of the component file.

  • effect

    none (default)blurgrayscalemonochromehigh-contrastsoftglasspixelatebitasciiwater

Props

ImageEffect

An image with CSS, SVG or canvas processing. Uses a 4:3 frame by default; change its aspect ratio with className.

PropTypeDefaultDescription
src / altstring–The source and required description of the image.
effectImageEffectNamenoneWhich image treatment to apply.
amountnumber0.75Effect intensity, clamped to zero through one.
tileSizenumber–Square glass tile, pixel block or character cell size in CSS pixels.
fit"cover" | "contain"coverCrop to fill, or keep the whole image in the frame.
crossOrigin"anonymous" | "use-credentials"–Optional image CORS mode. The source server must allow pixel access.
...propsReact.HTMLAttributes<HTMLDivElement>–Everything the native element accepts, such as `id`, `aria-*` and event handlers.

ImageEffectPicker

A single-choice ToggleGroup containing every effect. IMAGE_EFFECTS exports the same choices for custom controls.

PropTypeDefaultDescription
value / defaultValueImageEffectNamenoneControlled or initial selection.
onValueChange(effect: ImageEffectName) => void–Receives the selected effect.

Accessibility

The original image always carries the required alt text. Canvas and ASCII layers are decorative. Unreadable cross-origin pixels fall back to the image. Water becomes static with reduced motion. The effect picker reuses ToggleGroup keyboard navigation.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.