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

Function Radio

starters/hooks/src/RadioGroup.tsx:47–81  ·  view source on GitHub ↗
(props: AriaRadioProps)

Source from the content-addressed store, hash-verified

45}
46
47export function Radio(props: AriaRadioProps) {
48 let state = React.useContext(RadioContext)!;
49 let ref = useRef<HTMLInputElement>(null);
50 /*- begin highlight -*/
51 let {labelProps, inputProps, isSelected, isPressed, isDisabled} = useRadio(props, state, ref);
52 /*- end highlight -*/
53 let {hoverProps, isHovered} = useHover({isDisabled: isDisabled || state.isReadOnly});
54 let {isFocused, isFocusVisible, focusProps} = useFocusRing();
55
56 return (
57 <div
58 className="react-aria-RadioField"
59 data-selected={isSelected || undefined}
60 data-disabled={isDisabled || undefined}>
61 {/* The label wraps a visually hidden native radio input plus the styled indicator. */}
62 <label
63 {...mergeProps(labelProps, hoverProps)}
64 className="react-aria-RadioButton"
65 data-selected={isSelected || undefined}
66 data-pressed={isPressed || undefined}
67 data-hovered={isHovered || undefined}
68 data-focused={isFocused || undefined}
69 data-focus-visible={isFocusVisible || undefined}
70 data-disabled={isDisabled || undefined}
71 data-readonly={state.isReadOnly || undefined}
72 data-invalid={state.isInvalid || undefined}>
73 <VisuallyHidden elementType="span">
74 <input {...mergeProps(inputProps, focusProps)} ref={ref} />
75 </VisuallyHidden>
76 <div className="indicator" />
77 {props.children}
78 </label>
79 </div>
80 );
81}

Callers

nothing calls this directly

Calls 4

useHoverFunction · 0.90
useFocusRingFunction · 0.90
mergePropsFunction · 0.90
useRadioFunction · 0.85

Tested by

no test coverage detected