JGuang

ColorPicker

ColorPicker · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

ColorPicker

Used for select and display colors

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: Basic usage.
  • Controlled mode: The color picker panel synchronizes the values in the input boxes when opened.
  • Size: ColorPicker defines four sizes (mini, small, default, large), which are 24px, 28px, 32px, and 36px.
  • Disabled: Set disabled to disable the selector.
  • DisabledAlpha: Set disabledAlpha to hide the slider and value for Alpha. If the defaultValue has alpha (like #165DFF80), then the alpha value is retained for the intial render. The alpha value is reset and locked to 100 once the user clicks on the palette.
  • Color forma: Set the format of the color value through format, supporting hex and rgb.
  • Gradient color: Set the color mode to single color or gradient color through mode.
  • Preset & History: The preset color and history color areas can be opened through showPreset and showHistory. Historical colors require users to control the display content themselves.
  • Custom trigger: You can customize the trigger element of the color picker, and the properties related to the color input box will be invalid.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

ColorPicker

PropertyDescriptionTypeDefaultValueVersion
defaultPopupVisibleWhether the confirmation box is visible by defaultboolean--
disableddisabledboolean--
disabledAlphaDisable transparency channelboolean--
popupVisibleWhether the confirmation box is visibleboolean--
showHistoryShow history colorsboolean--
showPresetShow preset colorsboolean--
showTextShow color valueboolean--
unmountOnExitWhether to umount the node on hidingbooleantrue-
formatColor value format'hex' | 'rgb'--
sizeThe size of the input boxInputProps['size']default-
classNameAdditional css classstring | string[]--
defaultValueThe initial input contentstring | GradientColor[]--
historyColorsColor array of history colorsstring[]--
modeWhether to use single color or gradient color modeColorPickerMode | ColorPickerMode[]single-
presetColorsColor array of preset colorsstring[]--
styleAdditional styleCSSProperties--
triggerPropsAll Trigger component propsPartial<TriggerProps>--
valueThe input content valuestring | GradientColor[]--
onChangeCallback when the color value changes(value: string | GradientColor[]) => void--
onVisibleChangeCallback when popup shown or hidden.(visible: boolean) => void--
renderFooterCustomize the bottom content of the panel() => ReactNode-2.62.0
triggerElementThe trigger element which executes the dropdown action.ReactNode | ((params: { value: string | GradientColor[] }) => ReactNode)-2.60.0

GradientColor

export interface GradientColor {
  color: string;
  percent: number;
}

ColorPickerMode

export enum ColorPickerMode {
  Single = "single",
  Gradient = "gradient",
}