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

InputColor

원문 보기 위키 갱신

사용자가 색상을 선택할 수 있게 해 주는 컴포넌트예요.

출처: 문서

본문

InputColor는 사용자가 색상을 선택할 수 있게 해 주는 컴포넌트예요.

사용법 (Usage)

import { InputColor } from '@primereact/ui/inputcolor';
<InputColor.Root>
    <InputColor.Area>
        <InputColor.AreaBackground />
        <InputColor.AreaHandle />
    </InputColor.Area>
    <InputColor.Slider>
        <InputColor.TransparencyGrid />
        <InputColor.SliderTrack />
        <InputColor.SliderHandle />
    </InputColor.Slider>
    <InputColor.Swatch>
        <InputColor.TransparencyGrid />
        <InputColor.SwatchBackground />
    </InputColor.Swatch>
    <InputColor.EyeDropper>
        <EyeDropperIcon />
    </InputColor.EyeDropper>
    <InputColor.Input />
</InputColor.Root>
`InputColor.EyeDropper` uses the native EyeDropper API, which is not supported in some browsers (e.g. Firefox, Safari).

예제 (Examples)

기본 (Basic)

시각적 피커 인터페이스로 색상을 선택해요.

Popover와 함께 (With Popover)

InputColor를 Popover 안에 넣어서 컴포넌트 맨 위에 InputColor를 배치할 수 있어요.

세로 슬라이더 (Vertical Slider)

orientation prop으로 슬라이더의 방향을 바꿔요.

제어 (Controlled)

value와 onColorChange props로 색상을 제어해요.

고급 (Advanced)

colorManager

Color 클래스 (Color class)

Color 클래스는 모든 색상 클래스의 기반이 되는 클래스예요. 모든 색상 클래스에 필요한 기본 기능을 제공해요.

  • clone(): Clones the color.
  • toString(format): Converts the color to a string.
  • toFormat(format): Converts the color to a specific format.
  • toJSON(): Converts the color to a JSON object.
  • getChannelRange(channel): Returns the range of the channel.
  • getFormat(): Returns the format of the color.
  • getChannels(): Returns the channels of the color.
  • getChannelValue(channel): Returns the value of the channel.
  • getColorAxes(xyChannels): Returns the axes of the color.
  • incChannelValue(channel, step): Increments the value of the channel by the step.
  • decChannelValue(channel, step): Decrements the value of the channel by the step.
  • withChannelValue(channel, value): Returns a new color with the value of the channel changed.

하위 컴포넌트 (Sub-Components)

하위 컴포넌트의 props, state, exposes, 데이터 속성은 Primitive API에서 확인할 수 있어요.

훅 (Hooks)

useInputColor 훅 인터페이스는 Headless API에서 확인할 수 있어요.

접근성 (Accessibility)

WAI-ARIA 준수 상세와 키보드 지원은 InputColor Primitive에서 확인할 수 있어요.

테마 (Theming)

CSS 클래스 (CSS Classes)

styled 모드에서 사용하는 클래스 이름 목록이에요.

ClassName Description
p-input-color-area Class name of the area element
p-input-color-area-handle Class name of the area handle element
p-input-color-area-background Class name of the area background element
p-input-color-slider Class name of the slider element
p-input-color-slider-handle Class name of the slider handle element
p-input-color-slider-track Class name of the slider track element
p-input-color-transparency-grid Class name of the transparency grid element
p-input-color-swatch Class name of the swatch element
p-input-color-swatch-background Class name of the swatch background element
p-input-color-input Class name of the input element
p-input-color-eye-dropper Class name of the eye dropper element

디자인 토큰 (Design Tokens)

디자인 토큰 목록이에요.

Token CSS Variable Description
inputcolor.border.color --p-inputcolor-border-color Shared inset border color (area background, slider track, swatch background)
inputcolor.area.border.radius --p-inputcolor-area-border-radius Border radius of area
inputcolor.slider.border.radius --p-inputcolor-slider-border-radius Border radius of slider
inputcolor.slider.size --p-inputcolor-slider-size Size of slider (horizontal height / vertical width)
inputcolor.handle.size --p-inputcolor-handle-size Size of handle (area and slider)
inputcolor.handle.border.color --p-inputcolor-handle-border-color Border color of handle
inputcolor.handle.border.width --p-inputcolor-handle-border-width Border width of handle
inputcolor.handle.shadow --p-inputcolor-handle-shadow Shadow of handle
inputcolor.handle.transition.duration --p-inputcolor-handle-transition-duration Transition duration of handle
inputcolor.handle.focus.ring.border.width --p-inputcolor-handle-focus-ring-border-width Focus ring border width of handle
inputcolor.handle.focus.ring.border.color --p-inputcolor-handle-focus-ring-border-color Focus ring border color of handle
inputcolor.handle.focus.ring.outline.width --p-inputcolor-handle-focus-ring-outline-width Focus ring outline width of handle
inputcolor.handle.focus.ring.outline.color --p-inputcolor-handle-focus-ring-outline-color Focus ring outline color of handle
inputcolor.handle.focus.ring.outline.offset --p-inputcolor-handle-focus-ring-outline-offset Focus ring outline offset of handle
inputcolor.transparency.grid.color --p-inputcolor-transparency-grid-color Color of transparency grid (checker pattern)
inputcolor.transparency.grid.background --p-inputcolor-transparency-grid-background Background of transparency grid (checker base)
inputcolor.transparency.grid.tile.size --p-inputcolor-transparency-grid-tile-size Tile size of transparency grid
inputcolor.swatch.size --p-inputcolor-swatch-size Size of swatch
inputcolor.swatch.border.radius --p-inputcolor-swatch-border-radius Border radius of swatch

더 알아보기 (Learn more)