MCPcopy Create free account
hub / github.com/adobe/react-spectrum / TextField

Function TextField

starters/hooks/src/TextField.tsx:13–34  ·  view source on GitHub ↗
(props: TextFieldProps)

Source from the content-addressed store, hash-verified

11}
12
13export function TextField(props: TextFieldProps) {
14 let ref = useRef<HTMLInputElement>(null);
15 /*- begin highlight -*/
16 let {labelProps, inputProps} = useTextField(props, ref);
17 /*- end highlight -*/
18 let [isFocused, setFocused] = useState(false);
19 let {focusProps} = useFocus({onFocusChange: setFocused});
20
21 return (
22 <div className="react-aria-TextField">
23 <label className="react-aria-Label" {...labelProps}>
24 {props.label}
25 </label>
26 <input
27 {...mergeProps(inputProps, focusProps)}
28 ref={ref}
29 className="react-aria-Input inset"
30 data-focused={isFocused || undefined}
31 />
32 </div>
33 );
34}

Callers

nothing calls this directly

Calls 3

useTextFieldFunction · 0.90
useFocusFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected