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

Function RadioGroup

starters/hooks/src/RadioGroup.tsx:23–45  ·  view source on GitHub ↗
({children, ...props}: RadioGroupProps)

Source from the content-addressed store, hash-verified

21let RadioContext = React.createContext<RadioGroupState | null>(null);
22
23export function RadioGroup({children, ...props}: RadioGroupProps) {
24 let state = useRadioGroupState(props);
25 let {radioGroupProps, labelProps} = useRadioGroup(props, state);
26
27 return (
28 <div
29 {...radioGroupProps}
30 className="react-aria-RadioGroup"
31 data-orientation={props.orientation || 'vertical'}
32 data-invalid={state.isInvalid || undefined}
33 data-disabled={state.isDisabled || undefined}
34 data-readonly={state.isReadOnly || undefined}>
35 {props.label && (
36 <span {...labelProps} className="react-aria-Label">
37 {props.label}
38 </span>
39 )}
40 <div className="radio-items">
41 <RadioContext.Provider value={state}>{children}</RadioContext.Provider>
42 </div>
43 </div>
44 );
45}
46
47export function Radio(props: AriaRadioProps) {
48 let state = React.useContext(RadioContext)!;

Callers

nothing calls this directly

Calls 2

useRadioGroupStateFunction · 0.90
useRadioGroupFunction · 0.90

Tested by

no test coverage detected