ColorSlider

A color slider allows users to adjust an individual channel of a color value.

Theme 
 
colorSpace 
channel 
orientation 
isDisabled 
Example
ColorSlider.tsx
ColorSlider.css
import {ColorSlider} from './ColorSlider';

<ColorSlider
  channel="hue"
  defaultValue="hsl(0, 100%, 50%)" />

Value

Use the value or defaultValue prop to set the color value, and the channel prop to specify which color channel to display. The value may be a string or object, parsed using the function.

The onChange event is called as the user drags, and onChangeEnd is called when the thumb is released. These are always called with a Color object.

50°
onChange value: #FFD400
onChangeEnd value: #FFD400
import {parseColor} from 'react-aria-components';
import {ColorSlider} from './ColorSlider';
import {useState} from 'react';

function Example() {
  let [currentValue, setCurrentValue] = useState(parseColor('hsl(50, 100%, 50%)'));
  let [finalValue, setFinalValue] = useState(currentValue);

  return (
    <>
      <ColorSlider
        channel="hue"
        value={currentValue}
        onChange={setCurrentValue}
        onChangeEnd={setFinalValue} />
      <pre style={{fontSize: 12}}>
        onChange value: {currentValue.toString('hex')}{'\n'}
        onChangeEnd value: {finalValue.toString('hex')}
      </pre>
    </>
  );
}

API

Shows a color slider component with labels pointing to its parts, including the track, thumb, label, and output elements.ThumbTrackOutputLabelLabelHue230°
<ColorSlider>
  <Label />
  <SliderOutput />
  <SliderTrack>
    <ColorThumb />
  </SliderTrack>
</ColorSlider>

ColorSlider

A color slider allows users to adjust an individual channel of a color value.

NameTypeDefault
colorSpaceDefault:
The color space that the slider operates in. The channel must be in this color space. If not provided, this defaults to the color space of the color or defaultColor value.
channelDefault:
The color channel that the slider manipulates.
orientationDefault: 'horizontal'
The orientation of the Slider.
isDisabledbooleanDefault:
Whether the whole Slider is disabled.
children<>Default:
The children of the component. A function may be provided to alter the children based on component state.
valueTDefault:
The current value (controlled).
defaultValueTDefault:
The default value (uncontrolled).
onChange(value: ) => voidDefault:
Handler that is called when the value changes, as the user drags.
onChangeEnd(value: ) => voidDefault:
Handler that is called when the user stops dragging.

Default className: react-aria-ColorSlider

Render PropCSS Selector
orientationCSS Selector: [data-orientation="horizontal | vertical"]
The orientation of the color slider.
isDisabledCSS Selector: [data-disabled]
Whether the color slider is disabled.
stateCSS Selector:
State of the color slider.

ColorThumb

A color thumb appears within a ColorArea, ColorSlider, or ColorWheel and allows a user to drag to adjust the color value.

NameType
children<>
The children of the component. A function may be provided to alter the children based on component state.

Default className: react-aria-ColorThumb

Render PropCSS Selector
colorCSS Selector:
The selected color, excluding the alpha channel.
isDraggingCSS Selector: [data-dragging]
Whether this thumb is currently being dragged.
isHoveredCSS Selector: [data-hovered]
Whether the thumb is currently hovered with a mouse.
isFocusedCSS Selector: [data-focused]
Whether the thumb is currently focused.
isFocusVisibleCSS Selector: [data-focus-visible]
Whether the thumb is keyboard focused.
isDisabledCSS Selector: [data-disabled]
Whether the thumb is disabled.