Skip to Content

Scratch Reveal

Scratch reveal hover panel: painted paint wears away on hover to expose a pencil construction sketch, with the label switching to the canvas ink. Paint, canvas, sketch and ink default to theme colors; decorative, and reduced motion skips the fade.

Installation

pnpm dlx shadcn@latest add @01orbital/scratch-reveal

Usage

import { ScratchReveal } from "@/components/graphics/scratch-reveal"

// Every word on the page. Change copy here, not in the markup.
const COPY = {
  label: "Under the surface",
} as const

export default function ScratchRevealDemo() {
  return <ScratchReveal>{COPY.label}</ScratchReveal>
}

This example installs with everything it uses:

pnpm dlx shadcn@latest add @01orbital/scratch-reveal-demo

Examples

Project Briefscratch-reveal-project-brief

Portfolio project card example showing ScratchReveal: a reveal panel above the story, a serif heading and a folded brief.

pnpm dlx shadcn@latest add @01orbital/scratch-reveal-project-brief

Paper Stockscratch-reveal-paper-stock

Stock card example showing ScratchReveal: a letterpress paper stock card on deep teal with a reveal swatch and a specification list.

pnpm dlx shadcn@latest add @01orbital/scratch-reveal-paper-stock

API reference

A painted panel, 240 by 100px by default, with its children as a label. On hover the paint wears away to a pencil construction sketch and the label switches to the canvas ink.

Its colors are CSS variables you can set with className, each defaulting to a theme color: --scratch-paint and --scratch-paint-to (the paint's gradient, primary), --scratch-canvas (the canvas under it, muted), --scratch-sketch (the pencil marks, muted foreground; -line, -arc and -text tune each mark), --scratch-label (the label on the paint) and --scratch-ink (the label once revealed). The label takes the page font.

Decoration, not a control: there is no focus state, and reduced motion swaps without the fade. The label renders twice, once hidden from assistive tech, so keep it to plain text.

It accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs it for you.

Used in blocks

One block is built with Scratch Reveal.

Last updated on