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

Function CheckboxGroup

starters/hooks/src/CheckboxGroup.tsx:30–53  ·  view source on GitHub ↗
({children, orientation = 'vertical', ...props}: CheckboxGroupProps)

Source from the content-addressed store, hash-verified

28let CheckboxGroupContext = React.createContext<CheckboxGroupState | null>(null);
29
30export function CheckboxGroup({children, orientation = 'vertical', ...props}: CheckboxGroupProps) {
31 // useCheckboxGroupState manages the selected values for the group.
32 let state = useCheckboxGroupState(props);
33 let {groupProps, labelProps} = useCheckboxGroup(props, state);
34
35 return (
36 <div
37 {...groupProps}
38 className="react-aria-CheckboxGroup"
39 data-orientation={orientation}
40 data-readonly={state.isReadOnly || undefined}
41 data-invalid={state.isInvalid || undefined}
42 data-disabled={props.isDisabled || undefined}>
43 {props.label && (
44 <span {...labelProps} className="react-aria-Label">
45 {props.label}
46 </span>
47 )}
48 <div className="checkbox-items">
49 <CheckboxGroupContext.Provider value={state}>{children}</CheckboxGroupContext.Provider>
50 </div>
51 </div>
52 );
53}
54
55export function Checkbox(props: AriaCheckboxGroupItemProps) {
56 let state = React.useContext(CheckboxGroupContext)!;

Callers

nothing calls this directly

Calls 2

useCheckboxGroupStateFunction · 0.90
useCheckboxGroupFunction · 0.90

Tested by

no test coverage detected