Brand Color Input

Brand Color Input is a copy-paste React component that stops brand colour off by a hex digit 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/brand-color-input
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

StopsBrand colour off by a hex digit

Was this component page useful?

How do I install Brand Color Input?

pnpm dlx shadcn@latest add @bollard/brand-color-input

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

How do I use Brand Color Input in React?

brand-color-input-usage.tsx
import { BrandColorInput } from "@/components/ui/brand-color-input"

<BrandColorInput label="Button background" defaultValue="#1E40AE" palette={palette} />

What input mistakes does Brand Color Input catch?

  • Values a hair away from a palette token, with a snap to the token
  • The letter O typed for zero, and stray characters from a paste
  • A digit too many or too few
  • Alpha hidden in 4- and 8-digit hex
  • Android #AARRGGBB order, which CSS reads as a different colour

What props does Brand Color Input accept?

BrandColorInput props
PropTypeDefault
label

Visible label.

string"Colour"
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text on every change, including one-tap fixes.

(value: string) => void—
onColorChange

Called with the canonical hex the text renders as, or null when it can't be read.

(hex: string | null) => void—
palette

Brand tokens by name, e.g. { "blue-700": "#1e40af" }.

Record<string, string>NO_PALETTE
messages

Override any message.

Partial<typeof BRAND_COLOR_MESSAGES>—
snapLabel

Label of the one-tap fix that snaps to a token ("Use blue-700").

string"Use"
fixLabel

Label of the other one-tap fixes.

string"Fix to"

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

How is Brand Color Input accessible?

  • Visible <label>; the hint is linked with aria-describedby and is aria-live="polite"
  • aria-invalid when the value can't be read
  • Fix buttons have aria-labels naming the token and value; the swatch is aria-hidden
  • The flash on fix is skipped with prefers-reduced-motion

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

What are the limitations and server boundaries?

  • Only knows the palette you pass; with no palette it checks syntax only
  • "Close" is a perceptual distance threshold, so an intentional near-shade can be flagged

What expensive mistakes does Brand Color Input stop?

Brand colour off by a hex digit

Also known as

hex color · brand color · color input · design tokens · theme · palette · oklab · tailwind colors

Field type

What dependencies does Brand Color Input require?

Brand Color Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameBrand Color Input
Registry identifier@bollard/brand-color-input
Install commandnpx shadcn@latest add @bollard/brand-color-input
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 Brand Color Input

What form validation mistake does Brand Color Input catch?

Brand Color Input prevents brand colour off by a hex digit. A colour field that names the nearest brand token and offers a snap when a value is a hair off, so near-miss brand colours don't ship. Catches: Values a hair away from a palette token, with a snap to the token, The letter O typed for zero, and stray characters from a paste, A digit too many or too few, Alpha hidden in 4- and 8-digit hex, Android #AARRGGBB order, which CSS reads as a different colour. Limitation: validate brand-color-input schemas on backend.

How do I install brand-color-input with shadcn?

Run `npx shadcn@latest add @bollard/brand-color-input`. Sources added: registry/default/brand-color-input/brand-color-input.tsx, registry/default/brand-color-input/color.ts. Package requirements: lucide-react.

What props customize Brand Color Input?

Brand Color Input accepts `label`, `value`, `defaultValue`, `onValueChange`, `onColorChange`. Configures hex color, brand color, color input behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of brand-color-input?

Only knows the palette you pass; with no palette it checks syntax only. "Close" is a perceptual distance threshold, so an intentional near-shade can be flagged Server requirement: backend verification for brand-color-input.

How does Brand Color Input meet accessibility guidelines?

Visible <label>; the hint is linked with aria-describedby and is aria-live="polite". aria-invalid when the value can't be read. Fix buttons have aria-labels naming the token and value; the swatch is aria-hidden. The flash on fix is skipped with prefers-reduced-motion. Minimizes errors: hex color typo, off brand color.

Which components pair with Brand Color Input?