Usage
ColorInput
component supports Input and Input.Wrapper components features and all input
element props. ColorInput
documentation does not include all features supported by the component – see Input documentation to learn about all available features.
Input description
Controlled
Formats
Component supports hex, hexa, rgb, rgba, hsl and hsla color formats. Slider to change opacity is displayed only for hexa, 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:
Eye dropper
By default, if EyeDropper API
is available, eye dropper icon will be displayed at the right section of the input.
To disable it, set withEyeDropper={false}
.
Error state
Invalid name
Disabled state
Styles API
ColorInput
supports Styles API, you can add styles to any inner element of the component withclassNames
prop. Follow Styles API documentation to learn more.
Description
Error
Component Styles API
Hover over selectors to highlight corresponding elements
Get element ref
Accessibility
If ColorInput
is used without label
prop, it will not be announced properly by screen reader:
Set aria-label
to make the input accessible. In this case label will not be visible, but screen reader will announce it:
If label
prop is set, input will be accessible it is not required to set aria-label
: