alpha

useHexColorFieldState

installyarn add @react-stately/color
version3.0.0-alpha.1
usageimport {useHexColorFieldState} from '@react-stately/color'

API#


useHexColorFieldState( (props: HexColorFieldProps )): HexColorFieldState

Interface#


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.

Example#


See the docs for useHexColorField in react-aria for an example of useHexColorFieldState.