Provides the behavior and accessibility implementation for a color wheel component. Color wheels allow users to adjust the hue of an HSL or HSB color value on a circular track.
import {ColorWheel} from './ColorWheel';
<ColorWheel defaultValue="hsl(30, 100%, 50%)" />
API
<ColorWheel>
<ColorWheelTrack />
<ColorThumb />
</ColorWheel>
useColorWheelState (props: ColorWheelProps ): ColorWheelStateuseColorWheel(
props: AriaColorWheelOptions,
state: ColorWheelState,
inputRef: RefObject <HTMLInputElement | null >
): ColorWheelAriaColorWheelState
Properties
| Name | Type | |
|---|---|---|
hue | number | |
The current value of the hue channel displayed by the color wheel. | ||
isDragging | boolean | |
Whether the color wheel is currently being dragged. | ||
pageStep | number | |
The page step value of the hue channel, used when incrementing and decrementing. | ||
isDisabled | boolean | |
Whether the color wheel is disabled. | ||
value | Color | |
The current color value represented by the color wheel. | ||
defaultValue | Color | |
The default color value. | ||
Methods
setValue | ||
Sets the color value represented by the color wheel, and triggers onChange. | ||
setHue | ||
Sets the hue channel of the current color value and triggers onChange. | ||
setHueFromPoint(
x: number,
y: number,
radius: number
): void | ||
Sets the hue channel of the current color value based on the given coordinates and radius of
the color wheel, and triggers onChange. | ||
getThumbPosition | ||
| Returns the coordinates of the thumb relative to the center point of the color wheel. | ||
increment | ||
| Increments the hue by the given amount (defaults to 1). | ||
decrement | ||
| Decrements the hue by the given amount (defaults to 1). | ||
setDragging | ||
| Sets whether the color wheel is being dragged. | ||
getDisplayColor | ||
Returns the color that should be displayed in the color wheel instead of value. | ||
AriaColorWheelOptions
| Name | Type | |
|---|---|---|
outerRadius | number | |
The outer radius of the color wheel. | ||
innerRadius | number | |
The inner radius of the color wheel. | ||
isDisabled | boolean | |
Whether the ColorWheel is disabled. | ||
value | T | |
The current value (controlled). | ||
defaultValue | string | Color | |
The default value (uncontrolled). | ||
onChange | | |
Handler that is called when the value changes, as the user drags. | ||
onChangeEnd | | |
Handler that is called when the user stops dragging. | ||
ColorWheelAria
| Name | Type | |
|---|---|---|
trackProps | DOMAttributes | |
Props for the track element. | ||
thumbProps | DOMAttributes | |
Props for the thumb element. | ||
inputProps | InputHTMLAttributes | |
Props for the visually hidden range input element. | ||