본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Color Picker

원문 보기 위키 갱신

Color Picker (컬러 피커)

사용자가 컬러 피커에서 색상을 선택할 수 있게 해주는 컴포넌트예요. 색상 영역(area), 채널 슬라이더, 스와치(swatch) 등을 조합해 직관적인 색상 선택 UI를 만들 수 있어요.

출처: 문서

본문

구조 (Anatomy)

<ColorPicker.Root>
  <ColorPicker.Label />
  <ColorPicker.Control>
    <ColorPicker.ChannelInput />
    <ColorPicker.Trigger>
      <ColorPicker.ValueSwatch />
    </ColorPicker.Trigger>
  </ColorPicker.Control>
  <ColorPicker.Positioner>
    <ColorPicker.Content>
      <ColorPicker.Area>
        <ColorPicker.AreaBackground />
        <ColorPicker.AreaThumb />
      </ColorPicker.Area>
      <ColorPicker.EyeDropperTrigger />
      <ColorPicker.ChannelSlider>
        <ColorPicker.ChannelSliderTrack />
        <ColorPicker.ChannelSliderThumb />
      </ColorPicker.ChannelSlider>
      <ColorPicker.SwatchGroup>
        <ColorPicker.SwatchTrigger>
          <ColorPicker.Swatch />
        </ColorPicker.SwatchTrigger>
      </ColorPicker.SwatchGroup>
    </ColorPicker.Content>
  </ColorPicker.Positioner>
  <ColorPicker.HiddenInput />
</ColorPicker.Root>

예제 (Examples)

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { PipetteIcon } from 'lucide-react'
import styles from 'styles/color-picker.module.css'

export const Basic = () => {
  return (
    <ColorPicker.Root className={styles.Root} defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>

      <ColorPicker.Control className={styles.Control}>
        <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
        <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
        <ColorPicker.Trigger className={styles.Trigger}>
          <div className={styles.Swatch}>
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
          </div>
        </ColorPicker.Trigger>
      </ColorPicker.Control>

      <ColorPicker.Positioner>
        <ColorPicker.Content className={styles.Content}>
          <ColorPicker.Area className={styles.Area}>
            <ColorPicker.AreaBackground className={styles.AreaBackground} />
            <ColorPicker.AreaThumb className={styles.AreaThumb} />
          </ColorPicker.Area>
          <div className={styles.SliderGroup}>
            <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
              <PipetteIcon />
            </ColorPicker.EyeDropperTrigger>
            <div className={styles.ChannelSliders}>
              <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
                <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
              </ColorPicker.ChannelSlider>
              <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
                <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
              </ColorPicker.ChannelSlider>
            </div>
          </div>
        </ColorPicker.Content>
      </ColorPicker.Positioner>
      <ColorPicker.HiddenInput />
    </ColorPicker.Root>
  )
}

제어 (Controlled)

value와 onValueChange prop을 사용하면 컬러 피커의 상태를 프로그래밍 방식으로 제어할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { PipetteIcon } from 'lucide-react'
import { useState } from 'react'
import styles from 'styles/color-picker.module.css'

export const Controlled = () => {
  const [color, setColor] = useState(() => parseColor('hsl(20, 100%, 50%)'))

  return (
    <div className="stack">
      <output>Selected color: {color.toString('hex')}</output>

      <ColorPicker.Root className={styles.Root} value={color} onValueChange={(e) => setColor(e.value)}>
        <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>
        <ColorPicker.Control className={styles.Control}>
          <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
          <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
          <ColorPicker.Trigger className={styles.Trigger}>
            <div className={styles.Swatch}>
              <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
              <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
            </div>
          </ColorPicker.Trigger>
        </ColorPicker.Control>

        <ColorPicker.Positioner>
          <ColorPicker.Content className={styles.Content}>
            <ColorPicker.Area className={styles.Area}>
              <ColorPicker.AreaBackground className={styles.AreaBackground} />
              <ColorPicker.AreaThumb className={styles.AreaThumb} />
            </ColorPicker.Area>
            <div className={styles.SliderGroup}>
              <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
                <PipetteIcon />
              </ColorPicker.EyeDropperTrigger>
              <div className={styles.ChannelSliders}>
                <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
                  <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                  <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                </ColorPicker.ChannelSlider>
                <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
                  <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                  <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                  <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                </ColorPicker.ChannelSlider>
              </div>
            </div>
          </ColorPicker.Content>
        </ColorPicker.Positioner>

        <ColorPicker.HiddenInput />
      </ColorPicker.Root>
    </div>
  )
}

열림 제어 (Open Controlled)

open과 onOpenChange prop을 사용하면 컬러 피커 팝오버의 열림 상태를 프로그래밍 방식으로 제어할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { PipetteIcon } from 'lucide-react'
import { useState } from 'react'
import button from 'styles/button.module.css'
import styles from 'styles/color-picker.module.css'

export const OpenControlled = () => {
  const [open, setOpen] = useState(false)

  return (
    <div className="stack">
      <button className={button.Root} onClick={() => setOpen(!open)}>
        Toggle
      </button>

      <ColorPicker.Root
        className={styles.Root}
        open={open}
        onOpenChange={(e) => setOpen(e.open)}
        defaultValue={parseColor('#eb5e41')}
      >
        <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>
        <ColorPicker.Control className={styles.Control}>
          <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
          <ColorPicker.Trigger className={styles.Trigger}>
            <div className={styles.Swatch}>
              <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
              <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
            </div>
          </ColorPicker.Trigger>
        </ColorPicker.Control>

        <ColorPicker.Positioner>
          <ColorPicker.Content className={styles.Content}>
            <ColorPicker.Area className={styles.Area}>
              <ColorPicker.AreaBackground className={styles.AreaBackground} />
              <ColorPicker.AreaThumb className={styles.AreaThumb} />
            </ColorPicker.Area>
            <div className={styles.SliderGroup}>
              <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
                <PipetteIcon />
              </ColorPicker.EyeDropperTrigger>
              <div className={styles.ChannelSliders}>
                <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
                  <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                  <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                </ColorPicker.ChannelSlider>
                <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
                  <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                  <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                  <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                </ColorPicker.ChannelSlider>
              </div>
            </div>
          </ColorPicker.Content>
        </ColorPicker.Positioner>
        <ColorPicker.HiddenInput />
      </ColorPicker.Root>
    </div>
  )
}

RootProvider

컬러 피커를 제어하는 또 다른 방법으로 RootProvider 컴포넌트와 useColorPicker 훅을 사용할 수 있어요. 이렇게 하면 컴포넌트 외부에서도 상태와 메서드에 접근할 수 있어요.

import { ColorPicker, parseColor, useColorPicker } from '@ark-ui/react/color-picker'
import { CheckIcon, PipetteIcon } from 'lucide-react'
import styles from 'styles/color-picker.module.css'

const swatches = ['red', 'blue', 'green', 'orange']

export const RootProvider = () => {
  const colorPicker = useColorPicker({ defaultValue: parseColor('#eb5e41') })

  return (
    <div className="stack">
      <output>Color: {colorPicker.valueAsString}</output>

      <ColorPicker.RootProvider className={styles.Root} value={colorPicker}>
        <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>
        <ColorPicker.Control className={styles.Control}>
          <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
          <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
          <ColorPicker.Trigger className={styles.Trigger}>
            <div className={styles.Swatch}>
              <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
              <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
            </div>
          </ColorPicker.Trigger>
        </ColorPicker.Control>
        <ColorPicker.Positioner>
          <ColorPicker.Content className={styles.Content}>
            <ColorPicker.Area className={styles.Area}>
              <ColorPicker.AreaBackground className={styles.AreaBackground} />
              <ColorPicker.AreaThumb className={styles.AreaThumb} />
            </ColorPicker.Area>
            <div className={styles.SliderGroup}>
              <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
                <PipetteIcon />
              </ColorPicker.EyeDropperTrigger>
              <div className={styles.ChannelSliders}>
                <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
                  <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                  <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                </ColorPicker.ChannelSlider>
                <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
                  <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                  <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                  <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                </ColorPicker.ChannelSlider>
              </div>
            </div>
            <ColorPicker.SwatchGroup className={styles.SwatchGroup}>
              {swatches.map((color) => (
                <ColorPicker.SwatchTrigger key={color} className={styles.SwatchTrigger} value={color}>
                  <ColorPicker.Swatch className={styles.Swatch} value={color}>
                    <ColorPicker.SwatchIndicator className={styles.SwatchIndicator}>
                      <CheckIcon />
                    </ColorPicker.SwatchIndicator>
                  </ColorPicker.Swatch>
                </ColorPicker.SwatchTrigger>
              ))}
            </ColorPicker.SwatchGroup>
            <ColorPicker.View className={styles.View} format="rgba">
              <div className={styles.ChannelInputGroup}>
                <ColorPicker.ChannelInput className={styles.ChannelInput} channel="hex" />
                <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
              </div>
            </ColorPicker.View>
            <ColorPicker.View className={styles.View} format="hsla">
              <div className={styles.ChannelInputGroup}>
                <ColorPicker.ChannelInput className={styles.ChannelInput} channel="hue" />
                <ColorPicker.ChannelInput className={styles.ChannelInput} channel="saturation" />
                <ColorPicker.ChannelInput className={styles.ChannelInput} channel="lightness" />
              </div>
            </ColorPicker.View>
          </ColorPicker.Content>
        </ColorPicker.Positioner>
        <ColorPicker.HiddenInput />
      </ColorPicker.RootProvider>
    </div>
  )
}

비활성화 (Disabled)

disabled prop을 사용하면 컬러 피커를 비활성화할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import styles from 'styles/color-picker.module.css'

export const Disabled = () => {
  return (
    <ColorPicker.Root className={styles.Root} disabled defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>
      <ColorPicker.Control className={styles.Control}>
        <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
        <ColorPicker.Trigger className={styles.Trigger}>
          <div className={styles.Swatch}>
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
          </div>
        </ColorPicker.Trigger>
      </ColorPicker.Control>
      <ColorPicker.HiddenInput />
    </ColorPicker.Root>
  )
}

인라인 (Inline)

inline prop을 사용하면 팝오버 없이 컬러 피커를 인라인으로 렌더링할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { CheckIcon } from 'lucide-react'
import styles from 'styles/color-picker.module.css'

const swatches = ['red', 'blue', 'green', 'orange']

export const Inline = () => {
  return (
    <ColorPicker.Root className={styles.Root} inline defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Area className={styles.Area}>
        <ColorPicker.AreaBackground className={styles.AreaBackground} />
        <ColorPicker.AreaThumb className={styles.AreaThumb} />
      </ColorPicker.Area>

      <ColorPicker.SwatchGroup className={styles.SwatchGroup}>
        {swatches.map((color) => (
          <ColorPicker.SwatchTrigger key={color} className={styles.SwatchTrigger} value={color}>
            <ColorPicker.Swatch className={styles.Swatch} value={color}>
              <ColorPicker.SwatchIndicator className={styles.SwatchIndicator}>
                <CheckIcon />
              </ColorPicker.SwatchIndicator>
            </ColorPicker.Swatch>
          </ColorPicker.SwatchTrigger>
        ))}
      </ColorPicker.SwatchGroup>
    </ColorPicker.Root>
  )
}

입력 전용 (Input Only)

입력 필드, 값 스와치, 스포이드 트리거만 있는 최소한의 컬러 피커예요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { PipetteIcon } from 'lucide-react'
import styles from 'styles/color-picker.module.css'

export const InputOnly = () => {
  return (
    <ColorPicker.Root className={styles.Root} defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>
      <ColorPicker.Control className={styles.Control}>
        <ColorPicker.ValueSwatch className={styles.Swatch} />
        <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
        <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
          <PipetteIcon />
        </ColorPicker.EyeDropperTrigger>
      </ColorPicker.Control>
      <ColorPicker.HiddenInput />
    </ColorPicker.Root>
  )
}

슬라이더 전용 (Slider Only)

RGB 색상 선택을 위한 채널 슬라이더만 표시해요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import styles from 'styles/color-picker.module.css'

export const SliderOnly = () => {
  return (
    <ColorPicker.Root className={styles.Root} inline defaultValue={parseColor('#5dd016')}>
      <div className="hstack">
        <div className={styles.Swatch}>
          <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
          <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
        </div>
        <ColorPicker.ValueText className={styles.ValueText} />
      </div>
      <ColorPicker.View className={styles.View} format="rgba">
        <div className={styles.ChannelSliderRow}>
          <span className={styles.ChannelSliderLabel}>R</span>
          <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="red">
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
            <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
          </ColorPicker.ChannelSlider>
        </div>
        <div className={styles.ChannelSliderRow}>
          <span className={styles.ChannelSliderLabel}>G</span>
          <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="green">
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
            <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
          </ColorPicker.ChannelSlider>
        </div>
        <div className={styles.ChannelSliderRow}>
          <span className={styles.ChannelSliderLabel}>B</span>
          <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="blue">
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
            <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
          </ColorPicker.ChannelSlider>
        </div>
      </ColorPicker.View>
    </ColorPicker.Root>
  )
}

스와치 전용 (Swatch Only)

미리 정의된 색상 스와치만 있는 간단한 컬러 피커예요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { CheckIcon } from 'lucide-react'
import styles from 'styles/color-picker.module.css'

const swatches = ['red', 'pink', 'orange', 'purple']

export const SwatchOnly = () => {
  return (
    <ColorPicker.Root className={styles.Root} inline defaultValue={parseColor('#eb5e41')}>
      <output>
        Selected color: <ColorPicker.ValueText className={styles.ValueText} />
      </output>
      <ColorPicker.SwatchGroup className={styles.SwatchGroup}>
        {swatches.map((color) => (
          <ColorPicker.SwatchTrigger key={color} className={styles.SwatchTrigger} value={color}>
            <ColorPicker.Swatch className={styles.Swatch} value={color}>
              <ColorPicker.SwatchIndicator className={styles.SwatchIndicator}>
                <CheckIcon />
              </ColorPicker.SwatchIndicator>
            </ColorPicker.Swatch>
          </ColorPicker.SwatchTrigger>
        ))}
      </ColorPicker.SwatchGroup>
    </ColorPicker.Root>
  )
}

스와치 (Swatches)

빠른 색상 선택을 위해 컬러 피커 콘텐츠에 미리 정의된 색상 스와치를 포함할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { CheckIcon, PipetteIcon } from 'lucide-react'
import styles from 'styles/color-picker.module.css'

const swatches = ['red', 'blue', 'green', 'orange']

export const Swatches = () => {
  return (
    <ColorPicker.Root className={styles.Root} defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>

      <ColorPicker.Control className={styles.Control}>
        <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
        <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
        <ColorPicker.Trigger className={styles.Trigger}>
          <div className={styles.Swatch}>
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
          </div>
        </ColorPicker.Trigger>
      </ColorPicker.Control>

      <ColorPicker.Positioner>
        <ColorPicker.Content className={styles.Content}>
          <ColorPicker.Area className={styles.Area}>
            <ColorPicker.AreaBackground className={styles.AreaBackground} />
            <ColorPicker.AreaThumb className={styles.AreaThumb} />
          </ColorPicker.Area>
          <div className={styles.SliderGroup}>
            <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
              <PipetteIcon />
            </ColorPicker.EyeDropperTrigger>
            <div className={styles.ChannelSliders}>
              <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
                <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
              </ColorPicker.ChannelSlider>
              <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
                <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
              </ColorPicker.ChannelSlider>
            </div>
          </div>
          <ColorPicker.SwatchGroup className={styles.SwatchGroup}>
            {swatches.map((color) => (
              <ColorPicker.SwatchTrigger key={color} className={styles.SwatchTrigger} value={color}>
                <ColorPicker.Swatch className={styles.Swatch} value={color}>
                  <ColorPicker.SwatchIndicator className={styles.SwatchIndicator}>
                    <CheckIcon />
                  </ColorPicker.SwatchIndicator>
                </ColorPicker.Swatch>
              </ColorPicker.SwatchTrigger>
            ))}
          </ColorPicker.SwatchGroup>
        </ColorPicker.Content>
      </ColorPicker.Positioner>
      <ColorPicker.HiddenInput />
    </ColorPicker.Root>
  )
}

값 스와치 (Value Swatch)

색상 영역과 슬라이더 옆에 현재 색상 값을 스와치로 표시할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import styles from 'styles/color-picker.module.css'

export const ValueSwatch = () => {
  return (
    <ColorPicker.Root className={styles.Root} inline defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Area className={styles.Area}>
        <ColorPicker.AreaBackground className={styles.AreaBackground} />
        <ColorPicker.AreaThumb className={styles.AreaThumb} />
      </ColorPicker.Area>
      <div className={styles.SliderGroup}>
        <div className={styles.Swatch}>
          <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
          <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
        </div>
        <div className={styles.ChannelSliders}>
          <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
            <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
            <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
          </ColorPicker.ChannelSlider>
          <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
            <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
          </ColorPicker.ChannelSlider>
        </div>
      </div>
    </ColorPicker.Root>
  )
}

Field

Field 컴포넌트는 컬러 피커의 폼 관련 상태와 접근성 속성을 관리하는 데 도움을 줘요. ARIA 라벨, 도움말 텍스트, 오류 텍스트 처리를 포함해 적절한 접근성을 보장해요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { Field } from '@ark-ui/react/field'
import field from 'styles/field.module.css'
import styles from 'styles/color-picker.module.css'

export const WithField = () => (
  <Field.Root className={field.Root}>
    <ColorPicker.Root className={styles.Root} defaultValue={parseColor('#eb5e41')}>
      <ColorPicker.Label className={styles.Label}>Label</ColorPicker.Label>
      <ColorPicker.Control className={styles.Control}>
        <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
        <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
        <ColorPicker.Trigger className={styles.Trigger}>
          <div className={styles.Swatch}>
            <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
            <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
          </div>
        </ColorPicker.Trigger>
      </ColorPicker.Control>
      <ColorPicker.Positioner>
        <ColorPicker.Content className={styles.Content} />
      </ColorPicker.Positioner>
      <ColorPicker.HiddenInput />
    </ColorPicker.Root>
    <Field.HelperText className={field.HelperText}>Additional Info</Field.HelperText>
    <Field.ErrorText className={field.ErrorText}>Error Info</Field.ErrorText>
  </Field.Root>
)

폼 사용 (Form Usage)

HiddenInput 컴포넌트를 사용해 React Hook Form 같은 폼 라이브러리와 컬러 피커를 통합할 수 있어요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { PipetteIcon } from 'lucide-react'
import { useForm } from 'react-hook-form'
import button from 'styles/button.module.css'
import styles from 'styles/color-picker.module.css'

interface FieldValues {
  color: string
}

export const FormUsage = () => {
  const { register, handleSubmit } = useForm<FieldValues>()

  const onSubmit = (data: FieldValues) => {
    alert(data)
  }

  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <ColorPicker.Root className={styles.Root} inline defaultValue={parseColor('#eb5e41')}>
        <ColorPicker.HiddenInput {...register('color')} />

        <ColorPicker.Area className={styles.Area}>
          <ColorPicker.AreaBackground className={styles.AreaBackground} />
          <ColorPicker.AreaThumb className={styles.AreaThumb} />
        </ColorPicker.Area>
        <div className={styles.SliderGroup}>
          <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
            <PipetteIcon />
          </ColorPicker.EyeDropperTrigger>
          <div className={styles.ChannelSliders}>
            <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
              <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
              <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
            </ColorPicker.ChannelSlider>
            <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
              <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
              <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
              <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
            </ColorPicker.ChannelSlider>
          </div>
        </div>

        <ColorPicker.View className={styles.View} format="rgba">
          <div className={styles.ChannelInputGroup}>
            <ColorPicker.ChannelInput className={styles.ChannelInput} channel="hex" />
            <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
          </div>
        </ColorPicker.View>

        <ColorPicker.View className={styles.View} format="hsla">
          <div className={styles.ChannelInputGroup}>
            <ColorPicker.ChannelInput className={styles.ChannelInput} channel="hue" />
            <ColorPicker.ChannelInput className={styles.ChannelInput} channel="saturation" />
            <ColorPicker.ChannelInput className={styles.ChannelInput} channel="lightness" />
          </div>
        </ColorPicker.View>

        <button className={button.Root} type="submit" data-variant="solid">
          Submit
        </button>
      </ColorPicker.Root>
    </form>
  )
}

Dialog 안에서 사용 (Inside Dialog)

Dialog 안에서 컬러 피커를 사용하는 예시예요.

import { ColorPicker, parseColor } from '@ark-ui/react/color-picker'
import { Dialog } from '@ark-ui/react/dialog'
import { Portal } from '@ark-ui/react/portal'
import { PipetteIcon, XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import dialog from 'styles/dialog.module.css'
import styles from 'styles/color-picker.module.css'

export const InsideDialog = () => (
  <Dialog.Root>
    <Dialog.Trigger className={button.Root}>Open Dialog</Dialog.Trigger>
    <Portal>
      <Dialog.Backdrop className={dialog.Backdrop} />
      <Dialog.Positioner className={dialog.Positioner}>
        <Dialog.Content className={dialog.Content}>
          <Dialog.CloseTrigger className={dialog.CloseTrigger}>
            <XIcon />
          </Dialog.CloseTrigger>
          <Dialog.Title className={dialog.Title}>Choose a color</Dialog.Title>
          <Dialog.Description className={dialog.Description}>
            Wrap the positioner in a portal so the popover appears above the dialog.
          </Dialog.Description>
          <div className={dialog.Body}>
            <ColorPicker.Root className={styles.Root} defaultValue={parseColor('#eb5e41')} lazyMount unmountOnExit>
              <ColorPicker.Label className={styles.Label}>Color</ColorPicker.Label>

              <ColorPicker.Control className={styles.Control}>
                <ColorPicker.ChannelInput className={styles.Input} channel="hex" />
                <ColorPicker.ChannelInput className={styles.ChannelInput} channel="alpha" />
                <ColorPicker.Trigger className={styles.Trigger}>
                  <div className={styles.Swatch}>
                    <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                    <ColorPicker.ValueSwatch className={styles.ValueSwatch} />
                  </div>
                </ColorPicker.Trigger>
              </ColorPicker.Control>

              <Portal>
                <ColorPicker.Positioner>
                  <ColorPicker.Content className={styles.Content}>
                    <ColorPicker.Area className={styles.Area}>
                      <ColorPicker.AreaBackground className={styles.AreaBackground} />
                      <ColorPicker.AreaThumb className={styles.AreaThumb} />
                    </ColorPicker.Area>
                    <div className={styles.SliderGroup}>
                      <ColorPicker.EyeDropperTrigger className={styles.EyeDropperTrigger}>
                        <PipetteIcon />
                      </ColorPicker.EyeDropperTrigger>
                      <div className={styles.ChannelSliders}>
                        <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="hue">
                          <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                          <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                        </ColorPicker.ChannelSlider>
                        <ColorPicker.ChannelSlider className={styles.ChannelSlider} channel="alpha">
                          <ColorPicker.TransparencyGrid className={styles.TransparencyGrid} />
                          <ColorPicker.ChannelSliderTrack className={styles.ChannelSliderTrack} />
                          <ColorPicker.ChannelSliderThumb className={styles.ChannelSliderThumb} />
                        </ColorPicker.ChannelSlider>
                      </div>
                    </div>
                  </ColorPicker.Content>
                </ColorPicker.Positioner>
              </Portal>
              <ColorPicker.HiddenInput />
            </ColorPicker.Root>
          </div>
        </Dialog.Content>
      </Dialog.Positioner>
    </Portal>
  </Dialog.Root>
)

API 참조 (API Reference)

Props

Root

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

closeOnSelect Type: boolean Required: false Default Value: false Description: 스와치를 선택했을 때 컬러 피커를 닫을지 여부예요.

defaultFormat Type: ColorFormat Required: false Default Value: "rgba" Description: 렌더링될 때의 초기 색상 형식이에요. 컬러 피커의 색상 형식을 직접 제어할 필요가 없을 때 사용해요.

defaultOpen Type: boolean Required: false Default Value: undefined Description: 렌더링될 때 컬러 피커의 초기 열림 상태예요. 컬러 피커의 열림 상태를 직접 제어할 필요가 없을 때 사용해요.

defaultValue Type: Color Required: false Default Value: #000000 Description: 렌더링될 때의 초기 색상 값이에요. 컬러 피커의 색상 값을 직접 제어할 필요가 없을 때 사용해요.

disabled Type: boolean Required: false Default Value: undefined Description: 컬러 피커가 비활성화되었는지 여부예요.

format Type: ColorFormat Required: false Default Value: undefined Description: 사용할 제어된 색상 형식이에요.

hideMode Type: HideMode Required: false Default Value: 'display-none' Description: 마운트되었지만 표시되지 않을 때 콘텐츠를 숨기는 방법이에요.

  • 'display-none': HTML hidden 속성을 사용해요. 이펙트는 계속 동작해요.
  • 'activity': React 19 <Activity mode="hidden">을 사용해요. 이펙트가 일시 중지돼요. React 19+가 필요해요.

id Type: string Required: false Default Value: undefined Description: 머신의 고유 식별자예요.

ids Type: Partial<{ root: string; control: string; trigger: string; label: string; input: string; hiddenInput: string; content: string; area: string; areaGradient: string; positioner: string; formatSelect: string; areaThumb: string; channelInput: (id: string) => string; channelSliderTrack: (id: ColorChannel) => string; channe... Required: false Default Value: undefined Description: 컬러 피커 안 요소들의 id예요. 컴포지션에 유용해요.

immediate Type: boolean Required: false Default Value: undefined Description: 현재 변경을 즉시 동기화할지, 아니면 다음 프레임으로 지연할지 여부예요.

initialFocusEl Type: () => HTMLElement | null Required: false Default Value: undefined Description: 컬러 피커가 열렸을 때의 초기 포커스 요소예요.

inline Type: boolean Required: false Default Value: undefined Description: 컬러 피커를 인라인으로 렌더링할지 여부예요.

invalid Type: boolean Required: false Default Value: undefined Description: 컬러 피커가 유효하지 않은지 여부예요.

lazyMount Type: boolean Required: false Default Value: false Description: 지연 마운트를 활성화할지 여부예요.

name Type: string Required: false Default Value: undefined Description: 폼 입력을 위한 이름이에요.

onExitComplete Type: VoidFunction Required: false Default Value: undefined Description: 닫힌 상태에서 애니메이션이 끝날 때 호출되는 함수예요.

onFocusOutside Type: (event: FocusOutsideEvent) => void Required: false Default Value: undefined Description: 포커스가 컴포넌트 밖으로 이동했을 때 호출되는 함수예요.

onFormatChange Type: (details: FormatChangeDetails) => void Required: false Default Value: undefined Description: 색상 형식이 변경될 때 호출되는 함수예요.

onInteractOutside Type: (event: InteractOutsideEvent) => void Required: false Default Value: undefined Description: 컴포넌트 밖에서 상호작용이 발생했을 때 호출되는 함수예요.

onOpenChange Type: (details: OpenChangeDetails) => void Required: false Default Value: undefined Description: 사용자가 컬러 피커를 열거나 닫을 때 호출되는 핸들러예요.

onPointerDownOutside Type: (event: PointerDownOutsideEvent) => void Required: false Default Value: undefined Description: 컴포넌트 밖에서 포인터를 눌렀을 때 호출되는 함수예요.

onValueChange Type: (details: ValueChangeDetails) => void Required: false Default Value: undefined Description: 사용자가 드래그하는 동안 값이 변경될 때 호출되는 핸들러예요.

onValueChangeEnd Type: (details: ValueChangeDetails) => void Required: false Default Value: undefined Description: 사용자가 드래그를 멈출 때 호출되는 핸들러예요.

open Type: boolean Required: false Default Value: undefined Description: 컬러 피커의 제어된 열림 상태예요.

openAutoFocus Type: boolean Required: false Default Value: true Description: 컬러 피커가 열렸을 때 자동으로 포커스할지 여부예요.

positioning Type: PositioningOptions Required: false Default Value: undefined Description: 컬러 피커의 포지셔닝 옵션이에요.

present Type: boolean Required: false Default Value: undefined Description: 노드가 존재하는지(사용자가 제어) 여부예요.

readOnly Type: boolean Required: false Default Value: undefined Description: 컬러 피커가 읽기 전용인지 여부예요.

required Type: boolean Required: false Default Value: undefined Description: 컬러 피커가 필수인지 여부예요.

skipAnimationOnMount Type: boolean Required: false Default Value: false Description: 초기 등장 애니메이션을 허용할지 여부예요.

unmountOnExit Type: boolean Required: false Default Value: false Description: 종료 시 마운트를 해제할지 여부예요.

value Type: Color Required: false Default Value: undefined Description: 컬러 피커의 제어된 색상 값이에요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: root data-disabled: 비활성화됐을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요.

AreaBackground

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: area-background data-invalid: 유효하지 않을 때 표시돼요. data-disabled: 비활성화됐을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요.

Area

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

xChannel Type: ColorChannel Required: false Default Value: undefined Description: undefined

yChannel Type: ColorChannel Required: false Default Value: undefined Description: undefined

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: area data-invalid: 유효하지 않을 때 표시돼요. data-disabled: 비활성화됐을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요.

AreaThumb

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: area-thumb data-disabled: 비활성화됐을 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요.

ChannelInput

Props

channel Type: ExtendedColorChannel Required: true Default Value: undefined Description: undefined

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

orientation Type: Orientation Required: false Default Value: undefined Description: undefined

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: channel-input data-channel: channelinput의 색상 채널이에요. data-disabled: 비활성화됐을 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요.

ChannelSliderLabel

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: channel-slider-label data-channel: channelsliderlabel의 색상 채널이에요.

ChannelSlider

Props

channel Type: ColorChannel Required: true Default Value: undefined Description: undefined

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

orientation Type: Orientation Required: false Default Value: undefined Description: undefined

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: channel-slider data-channel: channelslider의 색상 채널이에요. data-orientation: channelslider의 방향이에요.

ChannelSliderThumb

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: channel-slider-thumb data-channel: channelsliderthumb의 색상 채널이에요. data-disabled: 비활성화됐을 때 표시돼요. data-orientation: channelsliderthumb의 방향이에요.

ChannelSliderTrack

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: channel-slider-track data-channel: channelslidertrack의 색상 채널이에요. data-orientation: channelslidertrack의 방향이에요.

ChannelSliderValueText

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: channel-slider-value-text data-channel: channelslidervaluetext의 색상 채널이에요.

Content

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: content data-placement: 콘텐츠의 배치 위치예요. data-nested: popover data-has-nested: popover data-side: 콘텐츠가 배치된 트리거의 면(측면)이에요. data-state: "open" | "closed"

Control

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: control data-disabled: 비활성화됐을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요. data-state: "open" | "closed" data-focus: 포커스됐을 때 표시돼요.

EyeDropperTrigger

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: eye-dropper-trigger data-disabled: 비활성화됐을 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요.

FormatSelect

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

FormatTrigger

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

HiddenInput

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

Label

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: label data-disabled: 비활성화됐을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요. data-required: 필수일 때 표시돼요. data-focus: 포커스됐을 때 표시돼요.

Positioner

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

RootProvider

Props

value Type: UseColorPickerReturn Required: true Default Value: undefined Description: undefined

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

hideMode Type: HideMode Required: false Default Value: 'display-none' Description: 마운트되었지만 표시되지 않을 때 콘텐츠를 숨기는 방법이에요.

  • 'display-none': HTML hidden 속성을 사용해요. 이펙트는 계속 동작해요.
  • 'activity': React 19 <Activity mode="hidden">을 사용해요. 이펙트가 일시 중지돼요. React 19+가 필요해요.

immediate Type: boolean Required: false Default Value: undefined Description: 현재 변경을 즉시 동기화할지, 아니면 다음 프레임으로 지연할지 여부예요.

lazyMount Type: boolean Required: false Default Value: false Description: 지연 마운트를 활성화할지 여부예요.

onExitComplete Type: VoidFunction Required: false Default Value: undefined Description: 닫힌 상태에서 애니메이션이 끝날 때 호출되는 함수예요.

present Type: boolean Required: false Default Value: undefined Description: 노드가 존재하는지(사용자가 제어) 여부예요.

skipAnimationOnMount Type: boolean Required: false Default Value: false Description: 초기 등장 애니메이션을 허용할지 여부예요.

unmountOnExit Type: boolean Required: false Default Value: false Description: 종료 시 마운트를 해제할지 여부예요.

SwatchGroup

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

SwatchIndicator

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

Swatch

Props

value Type: string | Color Required: true Default Value: undefined Description: 색상 값이에요.

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

respectAlpha Type: boolean Required: false Default Value: undefined Description: 색상에 알파 채널을 포함할지 여부예요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: swatch data-state: "checked" | "unchecked" data-value: 항목의 값이에요.

SwatchTrigger

Props

value Type: string | Color Required: true Default Value: undefined Description: 색상 값이에요.

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

disabled Type: boolean Required: false Default Value: undefined Description: swatch 트리거가 비활성화되었는지 여부예요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: swatch-trigger data-state: "checked" | "unchecked" data-value: 항목의 값이에요. data-disabled: 비활성화됐을 때 표시돼요.

TransparencyGrid

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

size Type: string Required: false Default Value: undefined Description: undefined

Trigger

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: trigger data-disabled: 비활성화됐을 때 표시돼요. data-readonly: 읽기 전용일 때 표시돼요. data-invalid: 유효하지 않을 때 표시돼요. data-placement: 트리거의 배치 위치예요. data-side: 트리거가 배치된 면(측면)이에요. data-state: "open" | "closed" data-focus: 포커스됐을 때 표시돼요.

ValueSwatch

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

respectAlpha Type: boolean Required: false Default Value: undefined Description: 색상에 알파 채널을 포함할지 여부예요.

ValueText

Props

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

format Type: ColorStringFormat Required: false Default Value: undefined Description: undefined

데이터 속성 (Data Attributes)

data-scope: color-picker data-part: value-text data-disabled: 비활성화됐을 때 표시돼요. data-focus: 포커스됐을 때 표시돼요.

View

Props

format Type: ColorFormat Required: true Default Value: undefined Description: undefined

asChild Type: boolean Required: false Default Value: undefined Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.

Context

API:

Property Type Description
dragging boolean 컬러 피커를 드래그하고 있는지 여부예요.
open boolean 컬러 피커가 열려 있는지 여부예요.
inline boolean 컬러 피커가 인라인으로 렌더링되는지 여부예요.
value Color 현재 색상 값(문자열 형태)이에요.
valueAsString string 현재 색상 값(Color 객체 형태)이에요.
setValue `(value: string Color) => void`
getChannelValue (channel: ColorChannel) => string 색상 값을 설정하는 함수예요.
getChannelValueText (channel: ColorChannel, locale: string) => string 특정 채널의 포맷 처리되고 지역화된 값을 가져오는 함수예요.
setChannelValue (channel: ColorChannel, value: number) => void 특정 채널의 색상 값을 설정하는 함수예요.
format ColorFormat 현재 색상 형식이에요.
setFormat (format: ColorFormat) => void 색상 형식을 설정하는 함수예요.
alpha number 색상의 알파 값이에요.
setAlpha (value: number) => void 색상 알파를 설정하는 함수예요.
setOpen (open: boolean) => void 컬러 피커를 열거나 닫는 함수예요.

접근성 (Accessibility)

키보드 지원 (Keyboard Support)

Enter Description: 포커스가 트리거에 있을 때 컬러 피커를 열어요.
포커스가 스와치의 트리거에 있을 때 색상을 선택하고(컬러 피커를 닫아요) 컬러 피커를 닫아요.
포커스가 입력 또는 채널 입력에 있을 때 색상을 선택해요.

ArrowLeft Description: 포커스가 색상 영역에 있을 때 색상의 hue 값을 감소시켜요.
포커스가 채널 슬라이더에 있을 때 채널의 값을 감소시켜요.

ArrowRight Description: 포커스가 색상 영역에 있을 때 색상의 hue 값을 증가시켜요.
포커스가 채널 슬라이더에 있을 때 채널의 값을 증가시켜요.

ArrowUp Description: 포커스가 색상 영역에 있을 때 색상의 saturation 값을 증가시켜요.
포커스가 채널 슬라이더에 있을 때 채널의 값을 증가시켜요.

ArrowDown Description: 포커스가 색상 영역에 있을 때 색상의 saturation 값을 감소시켜요.
포커스가 채널 슬라이더에 있을 때 채널의 값을 감소시켜요.

Esc Description: 컬러 피커를 닫고 포커스를 트리거로 이동해요.

더 알아보기 (Learn more)