Components · Forms · Color Picker
Back to Color Picker typesColor Picker
Use for any field where someone chooses a color - it shows the currently selected color as a swatch plus its hex value, and opens a palette of preset swatch options when focused or clicked.
Properties
Size, corner radius, label and color value are properties of the same component, not separate fields - change them below to check this field's style and states in the Live Preview.
Live Preview
Both types compared side by side, each in all 9 states. One full matrix is rendered per selected combination of Size and Corner radius - check more than one option in a dropdown to see every combination side by side.
Try it
A real, working Color Picker - click the field to open the palette, grouped into Brand, Neutral and Custom swatches, and click a swatch to select it. Escape or clicking outside closes the panel without changing the value.
When to use
Any field where someone chooses or edits a color, such as a brand color, theme customization, a chart series color, or a label highlight color.
Validation
The swatch and preset palette can't produce an invalid value by definition - validation is really about the typed or pasted hex text, since that's the only way to enter a value the component can't already guarantee is well-formed.
- Validation timing - validate the typed value on blur, not on every keystroke - a partial string like "#3a" is a normal in-progress state while typing, not an error.
- Format check - accept 3 or 6 hex digits after a #, adding the # automatically if it was left off, and accept rgb()/hsl() if the field supports those formats too.
- Error message - be specific about the expected format, e.g. "Enter a valid hex color, like #FF6B00," rather than a generic "Invalid color."
- Recovery - on an invalid blur, revert the text to the last valid color rather than leaving the mismatched text and swatch out of sync - or gray out the swatch until the value is corrected.
Component Guide
Overview
Color Picker shows the currently selected color as a swatch plus its hex value, and opens a palette of preset swatch options when focused or clicked - used for any field where the user chooses or edits a color rather than typing arbitrary text.
When to Use
- Brand color selection - picking a primary accent color for a theme.
- Theme customization - letting a user personalize colors in a settings panel.
- Assigning a color to a chart series or a label - so categories are visually distinguishable.
When Not to Use
- A value that isn't actually a color - use Input or Select for plain text or fixed options.
- A fixed, non-customizable color defined by the design system itself - there's no need for a picker when the value can never change.
- Selecting from a very large, unconstrained color space with precise numeric control (e.g. exact RGB channel entry) as the primary use case - pair the swatch picker with a text hex input, which this component already provides, rather than building a separate numeric-only control.
Best Practices
- Always show the current value as both a visual swatch and its hex code, since color alone can be hard to communicate precisely.
- Offer a curated preset palette in addition to free hex entry, so most users never need to type a hex value.
- Validate typed hex values immediately and fall back to the last valid color on invalid input, rather than letting the field go blank.
Do and Don't
Do
The swatch is paired with the hex value, so the choice can be read, copied and checked without trusting the screen's calibration.
Don't
A swatch with no value is unreadable to anyone who cannot distinguish it from the neighbouring shade, and impossible to reproduce elsewhere.
Accessibility
- The swatch alone never conveys the selected value - the hex text is always present for anyone who can't distinguish it visually.
- Preset swatches in the open panel are reachable and selectable by keyboard, not just by mouse click.
- The field's accessible name states what the color controls ("Brand color"), not just "Color".
Related Components
Input, Select, Slider.
{
"component": "Color Picker",
"category": "Forms",
"summary": "Color Picker shows the currently selected color as a swatch plus its hex value, and opens a palette of preset swatch options when focused or clicked - used for any field where the user chooses or edits a color rather than typing arbitrary text.",
"whenToUse": [
"Brand color selection - picking a primary accent color for a theme.",
"Theme customization - letting a user personalize colors in a settings panel.",
"Assigning a color to a chart series or a label - so categories are visually distinguishable."
],
"whenNotToUse": [
"A value that isn't actually a color - use Input or Select for plain text or fixed options.",
"A fixed, non-customizable color defined by the design system itself - there's no need for a picker when the value can never change.",
"Selecting from a very large, unconstrained color space with precise numeric control (e.g. exact RGB channel entry) as the primary use case - pair the swatch picker with a text hex input, which this component already provides, rather than building a separate numeric-only control."
],
"bestPractices": [
"Always show the current value as both a visual swatch and its hex code, since color alone can be hard to communicate precisely.",
"Offer a curated preset palette in addition to free hex entry, so most users never need to type a hex value.",
"Validate typed hex values immediately and fall back to the last valid color on invalid input, rather than letting the field go blank."
],
"doAndDont": {
"do": "The swatch is paired with the hex value, so the choice can be read, copied and checked without trusting the screen's calibration.",
"dont": "A swatch with no value is unreadable to anyone who cannot distinguish it from the neighbouring shade, and impossible to reproduce elsewhere."
},
"accessibility": [
"The swatch alone never conveys the selected value - the hex text is always present for anyone who can't distinguish it visually.",
"Preset swatches in the open panel are reachable and selectable by keyboard, not just by mouse click.",
"The field's accessible name states what the color controls (\"Brand color\"), not just \"Color\"."
],
"relatedComponents": [
"Input",
"Select",
"Slider"
]
}