dither-image
cult-ui/dither-imageFreeComponent
Compound Next.js image figure with CSS Bayer dither via dither-plugin, partial reveal overlays, and typed tuning props
Install it
npx shadcn@latest add https://raw.githubusercontent.com/nolly-studio/cult-ui/HEAD/apps/www/public/r/styles/default/dither-image.jsonSource
1"use client"23/**4 * `DitherImage` — compound figure that applies a CSS-only Bayer dither effect5 * to an image via the `dither-plugin` Tailwind utility. Safari-compatible (no6 * SVG filters), fully static (no JS runtime cost), and respects all the7 * plugin's tunable CSS custom properties as typed props.8 *9 * ## Installation10 *11 * ```bash12 * bun add dither-plugin13 * # or: npm install dither-plugin14 * # or: pnpm add dither-plugin15 * # or: yarn add dither-plugin16 * ```17 *18 * Then register the plugin in your Tailwind v4 stylesheet (alongside19 * `tailwindcss`):20 *21 * ```css22 * @import "tailwindcss";23 * @import "dither-plugin";24 * ```25 *26 * ## Usage27 *28 * ```tsx29 * <DitherImage>30 * <DitherImageFrame aspectRatio="square" size="md">31 * <DitherImageContent32 * src="/images/apple-wallpaper.jpg"33 * alt="Apple wallpaper"34 * fill35 * sizes="(min-width: 768px) 33vw, 100vw"36 * />37 * </DitherImageFrame>38 * <DitherImageCaption>Apple wallpaper, dithered</DitherImageCaption>39 * </DitherImage>40 * ```41 *42 * Partial dither (masked clean layer + optional `invertOnDark`):43 *44 * ```tsx45 * <DitherImageReveal className="size-72 overflow-hidden rounded-xl">46 * <DitherImageFrame invertOnDark size="lg" aspectRatio="square">47 * <DitherImageContent src="/photo.jpg" alt="" fill sizes="288px" />48 * </DitherImageFrame>49 * <DitherImageOverlay src="/photo.jpg" alt="" fill sizes="288px" from={0} to={65} />50 * </DitherImageReveal>51 * ```52 *53 * ## Notes54 *55 * - The dither class must live on a **wrapper** around the image. The plugin56 * paints the dot matrix via a `::after` pseudo-element, which `<img>` /57 * `<video>` elements do not render.58 * - The wrapper applies `filter: grayscale() brightness() blur() contrast()`59 * to all children. Render captions / overlay text **outside** the60 * `DitherImageFrame` (as `DitherImageCaption` does) so they stay crisp.61 * - `background: #000` ships from the plugin to give the `screen` blend-mode62 * something to lift against. Override with an inline background if needed.63 *64 * @see https://github.com/flornkm/dither-plugin65 */66import {67 createContext,68 forwardRef,69 useContext,70 type ComponentProps,71 type CSSProperties,72 type HTMLAttributes,73} from "react"74import Image, { type ImageProps } from "next/image"7576import { cn } from "@/lib/utils"7778/** Cell size of the underlying dither matrix — maps to plugin `--dither-cell-*` theme tokens. */79// … truncated
What it pulls in
npm packages
Files it writes
More from cult/ui
All 157 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-instructionsai-instructions | cult/ui | Components | Free | 2 deps | |
| ai-instructions-demoai-instructions-demo | cult/ui | Components | Free | no deps | |
| animated-numberanimated-number | cult/ui | Components | Free | 1 dep | |
| animated-number-demoanimated-number-demo | cult/ui | Components | Free | no deps | |
| bg-animate-buttonbg-animate-button | cult/ui | Components | Free | no deps | |
| bg-animate-button-demobg-animate-button-demo | cult/ui | Components | Free | no deps | |
| bg-animated-fractal-dot-gridbg-animated-fractal-dot-grid | cult/ui | Components | Free | 1 dep | |
| bg-animated-fractal-dot-grid-demobg-animated-fractal-dot-grid-demo | cult/ui | Components | Free | no deps |
