ColorPicker
Any colour, as a hex code, with the browser's picker beside it. The code is checked as it is typed.
import { ColorPicker } from '@sypnia/ui/react'
On this page
A brand colour
Saved as #4174bf
Code
import { useState } from 'react';
import { ColorPicker, Field } from '@sypnia/ui/react';
// Any colour as a hex code, with the browser's picker. Write «#12» to see the message.
export default function Brand() {
const [c, setC] = useState('#4174bf');
return <Field label="Brand colour" hint={`Saved as ${c}`}><ColorPicker value={c} onChange={setC} /></Field>;
} When to use it
Use it when
- Brand colours and themes.
Do not use it when
- A fixed set of colours: use ColorSwatchPicker.
For everyone
- The hex code is the main control; a wrong code says how to write it.
Props
| ColorPicker | Type | Default |
|---|---|---|
onChangerequired | (hex: string) => void | |
valuerequired | string | |
aria-describedby | string | |
aria-labelThe name for screen readers when there is no Field around it. | string | |
aria-labelledby | string | |
className | string | |
disabled | boolean | |
idInside a Field it comes from the Field. | string |