ColorSelector

ColorSelector is a component used by the user to select a color.

Usage

import { ColorPicker } from "@yamada-ui/react"
<ColorSelector.Root>
  <ColorSelector.SaturationSlider />
  <ColorSelector.HueSlider />
  <ColorSelector.AlphaSlider />
  <ColorSelector.ColorSwatchGroupLabel />
  <ColorSelector.ColorSwatchGroup>
    <ColorSelector.ColorSwatchItem />
  </ColorSelector.ColorSwatchGroup>
</ColorSelector.Root>

Change Size

Change Default Value

To change the default value, set defaultValue to a value.

Change Alpha Value

To change the alpha value, set defaultValue to a value containing the alpha value, or set format to "hexa" or "hsla" etc.

Change Color Swatches

To change the color swatches, set colorSwatches to an array.

Pick a color

Change Color Swatch Group Columns

To change the number of columns in the color swatch group, set colorSwatchGroupColumns to a number.

Pick a color

Change Shape

Make Disabled

Make Read Only

Customize Component

Control

Props

Accessibility

ColorSelector uses appropriate ARIA attributes to ensure accessibility for color selection.

Keyboard Navigation

KeyDescriptionState
ArrowRight, ArrowUpIf within a slider, increases the value based on step.-
ArrowLeft, ArrowDownIf within a slider, decreases the value based on step.-
HomeIf within hue slider or alpha slider, sets the value to min.-
EndIf within hue slider or alpha slider, sets the value to max.-
PageUpIf within hue slider or alpha slider, increases the value based on min and max.-
PageDownIf within hue slider or alpha slider, decreases the value based on min and max.-

ARIA Roles and Attributes

Component and ElementRole and AttributeUsage
ColorSelector.EyeDropperrole="button"Indicates that this is a button.
aria-disabledSets to "true" if disabled or readOnly is set.
aria-labelSets to "Pick a color".
aria-disabledSet to "true" if disabled is set.
ColorSelector.SaturationSlider > inputaria-hiddenExcludes the element from the accessibility tree.
aria-describedbyIf this is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
ColorSelector.SaturationSlider > divrole="slider"Indicates that this is a slider.
aria-labelSets to "Saturation and brightness thumb".
aria-describedbyIf this is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-roledescriptionSets to "2D slider".
aria-valueminSets the value of min. The default is 0.
aria-valuemaxSets the value of max. The default is 100.
aria-valuenowSets the current value.
aria-valuetextSets the current value like "Saturation 18%, Brightness 18%".
aria-readonlySet to "true" if readOnly is set.
aria-disabledSet to "true" if disabled is set.
ColorSelector.HueSlider > inputaria-hiddenExcludes the element from the accessibility tree.
aria-describedbyIf this is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
ColorSelector.HueSlider > divrole="slider"Indicates that this is a slider.
aria-labelSets to "Slider thumb".
aria-describedbyIf this is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-orientationSets to "horizontal" or "vertical" based on orientation. The default is "horizontal".
aria-valueminSets the value of min. The default is 0.
aria-valuemaxSets the value of max. The default is 360.
aria-valuenowSets the current value.
aria-valuetextSets the current value like "18°, Red".
aria-readonlySet to "true" if readOnly is set.
aria-disabledSet to "true" if disabled is set.
ColorSelector.AlphaSlider > inputaria-hiddenExcludes the element from the accessibility tree.
aria-describedbyIf this is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
ColorSelector.AlphaSlider > divrole="slider"Indicates that this is a slider.
aria-labelSets to "Slider thumb".
aria-describedbyIf this is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-orientationSets to "horizontal" or "vertical" based on orientation. The default is "horizontal".
aria-valueminSets the value of min. The default is 0.
aria-valuemaxSets the value of max. The default is 1.
aria-valuenowSets the current value.
aria-valuetextSets the current value like "18%".
aria-readonlySet to "true" if readOnly is set.
aria-disabledSet to "true" if disabled is set.
ColorSelector.ColorSwatchGroupLabelidUsed to associate with ColorSelector.ColorSwatchGroup.
ColorSelector.ColorSwatchGrouprole="listbox"Indicates that this is a listbox.
aria-labelledbySets the id of the associated ColorSelector.ColorSwatchGroupLabel.
ColorSelector.ColorSwatchItemrole="option"Indicates that this is an option.
aria-labelSets the current value.
aria-roledescriptionSets to "color swatch".
aria-selectedSets to "true" if value is the same as the current value.
aria-disabledSets to "true" if disabled or readOnly is set.

Similar Components

AlphaSlider

AlphaSlider is a component used to allow the user to select color transparency.

HueSlider

HueSlider is a component used to allow the user to select a color hue.

SaturationSlider

SaturationSlider is a component used to allow the user to select a color saturation.

ColorPicker

ColorPicker is a component used by the user to select a color or enter an arbitrary color value.

Checkbox

Checkbox is a component used for allowing users to select multiple values from multiple options.

Dropzone

Dropzone is a component used for uploading files via drag and drop.

Editable

Editable is a component used to obtain inline editable text input.

Field

Field is a component used to group form elements with label, helper message, error message, etc.

Uses Components & Hooks

Used By Components & Hooks