MCPcopy
hub / github.com/adobe/react-spectrum / useSwitch

Function useSwitch

packages/react-aria/src/switch/useSwitch.ts:60–77  ·  view source on GitHub ↗
(
  props: AriaSwitchProps,
  state: ToggleState,
  ref: RefObject<HTMLInputElement | null>
)

Source from the content-addressed store, hash-verified

58 * @param ref - Ref to the HTML input element.
59 */
60export function useSwitch(
61 props: AriaSwitchProps,
62 state: ToggleState,
63 ref: RefObject<HTMLInputElement | null>
64): SwitchAria {
65 let {labelProps, inputProps, isSelected, ...states} = useToggle(props, state, ref);
66
67 return {
68 labelProps,
69 inputProps: {
70 ...inputProps,
71 role: 'switch',
72 checked: isSelected
73 },
74 isSelected,
75 ...states
76 };
77}

Callers 2

Switch.tsxFile · 0.90
Switch.tsxFile · 0.90

Calls 1

useToggleFunction · 0.90

Tested by

no test coverage detected