ColorInput
Usage
Controlled
Formats
Component supports hex, rgb, rgba, hsl and hsla color formats. Slider to change opacity is displayed only for rgba and hsla formats:
Disable free input
To disable free input set disallowInput
prop:
With swatches
You can add any amount of predefined color swatches:
By default, there will be 10 swatches per row, you can change this with swatchesPerRow
prop,
like in ColorPicker component:
If you need to restrict color picking to certain colors – disable color picker and disallow free input:
Remove or replace preview
By default, color preview will be rendered on the left side of the input,
you can remove it (withPreview={false}
prop) or replace with any React node (icon
prop):
Input props
Right section
Disabled state
Validation state and error
Get input ref
Accessibility
Color picker focus
Color picker is not focusable, users without mouse access can select color only by entering it into input manually. If you want to make component accessible do not disable free input.
aria-label
Provide aria-label
in case you use component without label for screen reader support: