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

Function Checkbox

starters/hooks/src/CheckboxGroup.tsx:55–93  ·  view source on GitHub ↗
(props: AriaCheckboxGroupItemProps)

Source from the content-addressed store, hash-verified

53}
54
55export function Checkbox(props: AriaCheckboxGroupItemProps) {
56 let state = React.useContext(CheckboxGroupContext)!;
57 let ref = useRef<HTMLInputElement>(null);
58 /*- begin highlight -*/
59 let {inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid} = useCheckboxGroupItem(
60 props,
61 state,
62 ref
63 );
64 /*- end highlight -*/
65 let {hoverProps, isHovered} = useHover({isDisabled: isDisabled || isReadOnly});
66 let {isFocused, isFocusVisible, focusProps} = useFocusRing();
67
68 return (
69 <div className="react-aria-CheckboxField" data-disabled={isDisabled || undefined}>
70 <label
71 {...hoverProps}
72 className="react-aria-CheckboxButton"
73 data-selected={isSelected || undefined}
74 data-pressed={isPressed || undefined}
75 data-hovered={isHovered || undefined}
76 data-focused={isFocused || undefined}
77 data-focus-visible={isFocusVisible || undefined}
78 data-disabled={isDisabled || undefined}
79 data-readonly={isReadOnly || undefined}
80 data-invalid={isInvalid || undefined}>
81 <VisuallyHidden elementType="span">
82 <input {...mergeProps(inputProps, focusProps)} ref={ref} />
83 </VisuallyHidden>
84 <div className="indicator">
85 <svg viewBox="0 0 18 18" aria-hidden="true">
86 <polyline points="2 9 7 14 16 4" />
87 </svg>
88 </div>
89 {props.children}
90 </label>
91 </div>
92 );
93}

Callers

nothing calls this directly

Calls 4

useCheckboxGroupItemFunction · 0.90
useHoverFunction · 0.90
useFocusRingFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected