Controls
Swatch and hex field
a colour: the browser’s picker beside the hex as text · six digits apply as you type
function SwatchDemo() { const [hex, setHex] = React.useState('#2563eb'); return ( <div className={`flex flex-col gap-3 ${narrow}`}> <HexField label="Accent" value={hex} onChange={setHex} /> <div className="flex items-center gap-2"> {['#ffffff', '#111827', hex].map((h) => ( <Swatch key={h} hex={h} className="size-6" /> ))} </div> </div> );}API
<HexField label value onChange id? /> · <Swatch hex />Get it
Already in every copy of the web kit:
import { HexField, Swatch, readHex } from '@/components/controls/swatch';Details
- Exports
HexField,Swatch,readHex- Packages
- cn@^0.5.2
- Also searched as
- colour field, color picker, hex input, colour square
- Registry JSON
- /r/web/swatch.json
Agents: the whole registry is at /llms.txt.