Palette Guard

Palette Guard is a copy-paste React component that stops chart colours look identical to colour-blind readers before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/palette-guard
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsChart colours look identical to colour-blind readers

Was this component page useful?

How do I install Palette Guard?

pnpm dlx shadcn@latest add @bollard/palette-guard

The files land in your project. They're yours to edit.

How do I use Palette Guard in React?

palette-guard-usage.tsx
import { PaletteGuard, type Series } from "@/components/ui/palette-guard"

<PaletteGuard value={series} onValueChange={setSeries} />

What input mistakes does Palette Guard catch?

  • Series pairs that look alike for protan, deutan or tritan vision
  • Pairs already too close in normal vision
  • Smallest lightness-only fix that clears every clash
  • Cases needing patterns or direct labels instead

What props does Palette Guard accept?

PaletteGuard props
PropTypeDefault
value

Controlled palette, one entry per chart series.

Series[]—
defaultValue

Initial palette when uncontrolled.

Series[][]
onValueChange

Called with the new palette when a colour is edited or a fix is applied.

(value: Series[]) => void—
minDelta

Smallest CIEDE2000 difference that still reads as two series. 6 passes Okabe–Ito and fails red/green.

number6
visionLabels

Row names for each kind of vision.

Record<Vision, string>{ normal: "Typical vision", protan: "Red-blind (protan)",…
clashText

Templates: `{a}`, `{b}`, `{vision}`, `{delta}`, `{name}`, `{direction}`.

string"{a} and {b} look alike to {vision} readers (ΔE {delta})."
normalClashText

Shown when a pair is too close in normal vision.

string"{a} and {b} are hard to tell apart for everyone (ΔE {del…
fixText

Fix button template.

string"{direction} {name}"
noFixText

Shown when no lightness change can clear every clash.

string"No colour change separates them without breaking another…
passText

Shown when every pair is distinguishable.

string"All {count} series stay distinct for red-, green- and bl…

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Palette Guard accessible?

  • Series list is labelled; each colour input has an aria-label
  • Clash status is in a polite live region and marked in text (", clashes")
  • Fix button has an aria-label describing the change

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • Simulates full dichromacy (severity 1.0); milder forms are not modelled separately
  • A colour difference threshold isn't the same as legibility on your background
  • Doesn't check text contrast

What expensive mistakes does Palette Guard stop?

Chart colours look identical to colour-blind readers

Also known as

color palette · colour blind · chart colors · a11y · deuteranopia · okabe-ito · data viz · contrast

What dependencies does Palette Guard require?

Palette Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component namePalette Guard
Registry identifier@bollard/palette-guard
Install commandnpx shadcn@latest add @bollard/palette-guard
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Palette Guard

What form validation mistake does Palette Guard catch?

Palette Guard prevents chart colours look identical to colour-blind readers. Simulates colour-blind vision for chart series and flags pairs that become hard to tell apart, with the smallest lightness fix. Catches: Series pairs that look alike for protan, deutan or tritan vision, Pairs already too close in normal vision, Smallest lightness-only fix that clears every clash, Cases needing patterns or direct labels instead. Limitation: validate palette-guard schemas on backend.

How do I install palette-guard with shadcn?

Run `npx shadcn@latest add @bollard/palette-guard`. Sources added: registry/default/palette-guard/palette-guard.tsx, registry/default/palette-guard/palette-math.ts. Package requirements: lucide-react.

What props customize Palette Guard?

Palette Guard accepts `value`, `defaultValue`, `onValueChange`, `minDelta`, `visionLabels`. Configures color palette, colour blind, chart colors behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of palette-guard?

Simulates full dichromacy (severity 1.0); milder forms are not modelled separately. A colour difference threshold isn't the same as legibility on your background. Doesn't check text contrast Server requirement: backend verification for palette-guard.

How does Palette Guard meet accessibility guidelines?

Series list is labelled; each colour input has an aria-label. Clash status is in a polite live region and marked in text (", clashes"). Fix button has an aria-label describing the change. Minimizes errors: colour blind chart, red green chart.

Which components pair with Palette Guard?