useColorField
Provides the behavior and accessibility implementation for a color field component. Color fields allow users to enter and adjust a hex color value.
install | yarn add @react-aria/color |
---|---|
version | 3.0.0-alpha.0 |
usage | import {useColorField} from '@react-aria/color' |
API#
useColorField(
props: AriaColorFieldProps,
state: ColorFieldState,
ref: RefObject<HTMLInputElement>
): ColorFieldAria
Example#
import {useColorFieldState} from '@react-stately/color';
function ColorField(props) {
let state = useColorFieldState(props);
let inputRef = ReactuseRef();
let {labelProps inputProps} = useColorField(props state inputRef);
return (
<div style={display: 'inline-flex' flexDirection: 'column'}>
<label ...labelProps> propslabel</label>
<input ...inputProps ref= inputRef />
</div>
);
}
<ColorField label="Color" />
import {useColorFieldState} from '@react-stately/color';
function ColorField(props) {
let state = useColorFieldState(props);
let inputRef = ReactuseRef();
let {labelProps inputProps} = useColorField(
props
state
inputRef
);
return (
<div
style={
display: 'inline-flex'
flexDirection: 'column'
}>
<label ...labelProps> propslabel</label>
<input ...inputProps ref= inputRef />
</div>
);
}
<ColorField label="Color" />
import {useColorFieldState} from '@react-stately/color';
function ColorField(
props
) {
let state = useColorFieldState(
props
);
let inputRef = ReactuseRef();
let {
labelProps
inputProps
} = useColorField(
props
state
inputRef
);
return (
<div
style={
display:
'inline-flex'
flexDirection:
'column'
}>
<label
...labelProps>
propslabel
</label>
<input
...inputProps
ref= inputRef
/>
</div>
);
}
<ColorField label="Color" />