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

useHexColorField

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

API#


useHexColorField( props: AriaHexColorFieldProps<AriaHexColorFieldProps, 'value' | 'defaultValue' | 'onChange'>, state: HexColorFieldState, ref: RefObject<HTMLInputElement> ): HexColorFieldAria

Features#


NameTypeDescription
valueColorInput
defaultValueColorInput
onChange( (color: Color )) => void
stepnumber
isDisabledbooleanWhether the input is disabled.
isReadOnlybooleanWhether the input can be selected but not changed by the user.
validationStateValidationStateWhether the input should display its "valid" or "invalid" visual styling.
isRequiredbooleanWhether user input is required on the input before form submission. Often paired with the necessityIndicator prop to add a visual indicator to the input.
autoFocusbooleanWhether the element should receive focus on render.
onFocus( (e: FocusEvent )) => voidHandler that is called when the element receives focus.
onBlur( (e: FocusEvent )) => voidHandler that is called when the element loses focus.
onFocusChange( (isFocused: boolean )) => voidHandler that is called when the element's focus status changes.
onKeyDown( (e: KeyboardEvent )) => voidHandler that is called when a key is pressed.
onKeyUp( (e: KeyboardEvent )) => voidHandler that is called when a key is released.
placeholderstringTemporary text that occupies the text input when it is empty.
labelReactNodeThe content to display as the label.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
excludeFromTabOrderbooleanWhether 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.
idstringThe element's unique identifier. See MDN.
autoCompletestringDescribes the type of autocomplete functionality the input should provide if any. See MDN.
maxLengthnumberThe maximum number of characters supported by the input. See MDN.
minLengthnumberThe minimum number of characters required by the input. See MDN.
namestringThe name of the input element, used when submitting an HTML form. See MDN.
patternstringRegex pattern that the value of the input must match to be valid. See MDN.
type'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | stringThe type of input to render. See MDN.
inputMode'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'Hints at the type of data that might be entered by the user while editing the element or its contents. See MDN.
onCopyClipboardEventHandler<HTMLInputElement>Handler that is called when the user copies text. See MDN.
onCutClipboardEventHandler<HTMLInputElement>Handler that is called when the user cuts text. See MDN.
onPasteClipboardEventHandler<HTMLInputElement>Handler that is called when the user pastes text. See MDN.
onCompositionStartCompositionEventHandler<HTMLInputElement>Handler that is called when a text composition system starts a new text composition session. See MDN.
onCompositionEndCompositionEventHandler<HTMLInputElement>Handler that is called when a text composition system completes or cancels the current text composition session. See MDN.
onCompositionUpdateCompositionEventHandler<HTMLInputElement>Handler that is called when a new character is received in the current text composition session. See MDN.
onSelectReactEventHandler<HTMLInputElement>Handler that is called when text in the input is selected. See MDN.
onBeforeInputFormEventHandler<HTMLInputElement>Handler that is called when the input value is about to be modified. See MDN.
onInputFormEventHandler<HTMLInputElement>Handler that is called when the input value is modified. See MDN.
aria-errormessagestringIdentifies the element that provides an error message for the object.
string | Color
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'

A list of color channels.

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

Properties

NameTypeDescription
colorValueColor
setInputValue( (value: string )) => void
inputValuestringThe current text value of the input. Updated as the user types, and formatted according to formatOptions on blur.

Methods

MethodDescription
commit(): voidCommits the current input value. The value is parsed to a number, clamped according to the minimum and maximum values of the field, and snapped to the nearest step value. This will fire the onChange prop with the new value, and if uncontrolled, update the numberValue. Typically this is called when the field is blurred.
increment(): voidIncrements the current input value to the next step boundary, and fires onChange.
decrement(): voidDecrements the current input value to the next step boundary, and fires onChange.
incrementToMax(): voidSets the current value to the maxValue if any, and fires onChange.
decrementToMin(): voidSets the current value to the minValue if any, and fires onChange.
NameTypeDescription
labelPropsLabelHTMLAttributes<HTMLLabelElement>
inputPropsHTMLAttributes<HTMLInputElement>

Contents

  • API
  • Features

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