Color Field

A color field allows users to adjust a hex color or fine-tune individual color channels, offering precise control over color customization.

Basic

A color field allows users to adjust a hex color or manipulate individual color channels.

Installation

If you hit any issues, make sure you check out the installation guide here.

Composed Components

When you plug this component from the CLI, it autoloads all the composed components. No need to toss 'em in one at a time.

The Color Field's decked out with several components to make it bangin'.

Color Picker

A Color Picker keeps color values in sync across React Aria color components. It makes building color pickers with custom layouts a breeze through composition.

Field

Field's a core piece every other component uses. It flexes reusable styles, showing up in inputs, labels, descriptions, and more.

Color Swatch

A visual lineup of colors, letting you pick with a click, just like choosing your next outfit from your wardrobe.

Manual Installation

Sometimes, using the CLI is the way to go, so make sure you install the necessary dependencies for the components you want to use.

Anatomy

Import the components and use them as shown below, adapting the structure to fit each component.

Prefix

A color field can include a prefix to provide context or functionality.

Suffix

A color field can also have a suffix.

Controlled

Manage the color field in a controlled manner to automatically update the ColorSwatch and display the current color.

hex#FAFAFAhexa#FAFAFAFFrgbrgb(250, 250, 250)rgbargba(250, 250, 250, 1)hslhsl(0, 0%, 98.04%)hslahsla(0, 0%, 98.04%, 1)hsbhsb(0, 0%, 98.04%)hsbahsba(0, 0%, 98.04%, 1)

You can typically click the color swatch to open the color picker. To disable this feature, set enableColorPicker to false.

<ColorField enableColorPicker={false}/>

Disabled

You can disable the color field, making it non-interactive.

Validation

In this example, we’ll ensure it’s treated as a strict requirement.

Props

The ColorField component includes all standard props from react-aria-components, plus these additional features:

PropertyTypeOptional
labelstringYes
descriptionstringYes
errorMessagestring | ((validation: ValidationResult) => string)Yes
placeholderstringYes
prefixReact.ReactNodeYes
suffixReact.ReactNodeYes
isLoadingbooleanYes
enableColorPickerbooleanYes ( default: true)