The ColorInput component provides an enhanced color picker that displays the selected color as a visual preview alongside its hex value. It extends the standard HTML color input with a more user-friendly interface.
- Color Preview: Shows a visual preview of the selected color
- Hex Value Display: Displays the hex code of the selected color
- Native Color Picker: Uses the browser's native color picker for selection
- Reset Option: Includes a button to clear the selected color
- Alpha Support: Optional opacity/transparency control via dropdown slider
Enable alpha channel (transparency) control by setting supportAlpha to true. This adds an opacity button that opens a dropdown with a slider to adjust transparency from 0-100%.
When supportAlpha is enabled:
- The value is automatically converted to rgba(r, g, b, a) format
- An opacity icon appears in the input suffix
- Clicking the icon opens a dropdown with a slider (0-100% opacity)
- The color preview shows transparency
- The display text shows RGBA values
label and description are yours to translate. The field's own controls take labels: remove for the clear button ("Remove"), adjustOpacity for the opacity button ("Adjust opacity") and opacity for its slider ("Opacity"). Whatever you leave out stays English.
size="xxs" draws a 32px field, the height of a size="s" Button. The label shows as the placeholder until a colour is picked.
The ColorInput component extends the standard Input component props with the following modifications: