React Aria

  • Introduction

    • Getting Started
    • Why React Aria?
  • Concepts

    • Accessibility
    • Interactions
    • Internationalization
    • Server Side Rendering
  • Interactions

    • useFocus
    • useFocusVisible
    • useFocusWithin
    • useHover
    • useKeyboard
    • useMove
    • usePress
  • Buttons

    • useButton
    • useToggleButton
  • Collections

    • useListBox
    • useMenu
  • Color

    • useColorSlideralpha
    • useColorWheelalpha
    • useHexColorFieldalpha
  • Focus

    • FocusRing
    • FocusScope
    • useFocusRing
  • Forms

    • useCheckbox
    • useCheckboxGroup
    • useNumberFieldalpha
    • useRadioGroup
    • useSearchField
    • useSelect
    • useSwitch
    • useTextField
  • Navigation

    • useBreadcrumbs
    • useLink
  • Overlays

    • DismissButton
    • useDialog
    • useMenuTrigger
    • useModal
    • useOverlay
    • useOverlayPosition
    • useOverlayTrigger
    • usePreventScroll
    • useTooltipTrigger
    • watchModals
  • Sliders

    • useSlider
  • Status

    • useMeter
    • useProgressBar
  • Content

    • useSeparator
  • Internationalization

    • I18nProvider
    • useCollator
    • useDateFormatter
    • useFilter
    • useLocale
    • useMessageFormatter
    • useNumberFormatter
  • Server Side Rendering

    • SSRProvider
    • useIsSSR
  • Utilities

    • VisuallyHidden
    • mergeProps
    • useId
    • useLabel
alpha

useColorSlider

installyarn add @react-aria/color
version3.0.0-alpha.1
usageimport {useColorSlider} from '@react-aria/color'
View ARIA spec
W3C
View repository
GitHub
View package
NPM

API#


useColorSlider( (props: ColorSliderAriaOptions, , state: ColorSliderState )): ColorSliderAria

Features#


NameTypeDefaultDescription
channelColorChannel—
trackRefRefObject<HTMLElement>—
inputRefRefObject<HTMLInputElement>—
orientationOrientation'horizontal'The orientation of the Slider.
isDisabledboolean—Whether the Thumb is disabled.
autoFocusboolean—Whether the element should receive focus on render.
onFocus( (e: FocusEvent )) => void—Handler that is called when the element receives focus.
onBlur( (e: FocusEvent )) => void—Handler that is called when the element loses focus.
onFocusChange( (isFocused: boolean )) => void—Handler that is called when the element's focus status changes.
onKeyDown( (e: KeyboardEvent )) => void—Handler that is called when a key is pressed.
onKeyUp( (e: KeyboardEvent )) => void—Handler that is called when a key is released.
validationStateValidationState—Whether the input should display its "valid" or "invalid" visual styling.
isRequiredboolean—Whether user input is required on the input before form submission. Often paired with the necessityIndicator prop to add a visual indicator to the input.
labelReactNode—The content to display as the label.
idstring—The element's unique identifier. See MDN.
excludeFromTabOrderboolean—Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available.
aria-labelstring—Defines a string value that labels the current element.
aria-labelledbystring—Identifies the element (or elements) that labels the current element.
aria-describedbystring—Identifies the element (or elements) that describes the object.
aria-detailsstring—Identifies the element (or elements) that provide a detailed, extended description for the object.
aria-errormessagestring—Identifies the element that provides an error message for the object.

A list of color channels.

'hue' | 'saturation' | 'brightness' | 'lightness' | 'red' | 'green' | 'blue' | 'alpha'
'horizontal' | 'vertical'
BaseEvent<ReactKeyboardEvent<any>>
T & {
stopPropagation: () => void,
continuePropagation: () => void
}
'valid' | 'invalid'

Properties

NameTypeDescription
valueColor
valuesnumber[]Values managed by the slider by thumb index.
focusedThumbnumber | undefinedCurrently-focused thumb index.
stepnumberThe step amount for the slider.

Methods

MethodDescription
setValue( (value: string |  | Color )): void
getDisplayColor( (c: Color )): ColorReturns the color that should be displayed in the slider instead of value or the optional parameter.
getThumbValue( (index: number )): numberGet the value for the specified thumb.
setThumbValue( (index: number, , value: number )): voidSets the value for the specified thumb. The actual value set will be clamped and rounded according to min/max/step.
setThumbPercent( (index: number, , percent: number )): voidSets value for the specified thumb by percent offset (between 0 and 1).
isThumbDragging( (index: number )): booleanWhether the specific thumb is being dragged.
setThumbDragging( (index: number, , dragging: boolean )): voidSet is dragging on the specified thumb.
setFocusedThumb( (index: number |  | undefined )): voidSet focused true on specified thumb. This will remove focus from any thumb that had it before.
getThumbPercent( (index: number )): numberReturns the specified thumb's value as a percentage from 0 to 1.
getValuePercent( (value: number )): numberReturns the value as a percent between the min and max of the slider.
getThumbValueLabel( (index: number )): stringReturns the string label for the specified thumb's value, per props.formatOptions.
getFormattedValue( (value: number )): stringReturns the string label for the value, per props.formatOptions.
getThumbMinValue( (index: number )): numberReturns the min allowed value for the specified thumb.
getThumbMaxValue( (index: number )): numberReturns the max allowed value for the specified thumb.
getPercentValue( (percent: number )): numberConverts a percent along track (between 0 and 1) to the corresponding value.
isThumbEditable( (index: number )): booleanReturns if the specified thumb is editable.
setThumbEditable( (index: number, , editable: boolean )): voidSet the specified thumb's editable state.
MethodDescription
toFormat( (format: ColorFormat )): Color
toHexInt(): number
getChannelValue( (channel: ColorChannel )): number
withChannelValue( (channel: ColorChannel, , value: number )): Color

A list of supported color formats.

'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsb' | 'hsba'
NameTypeDescription
groupPropsHTMLAttributes<HTMLElement>
trackPropsHTMLAttributes<HTMLElement>
inputPropsHTMLAttributes<HTMLElement>
thumbPropsHTMLAttributes<HTMLElement>
labelPropsHTMLAttributes<HTMLElement>
outputPropsHTMLAttributes<HTMLElement>
gradientPropsHTMLAttributes<HTMLElement>

Contents

  • API
  • Features

  • Copyright © 2021 Adobe. All rights reserved.
  • Privacy
  • Terms of Use
  • Cookies
  • Do not sell my personal information