import { useRef } from "react"; import { AriaSwitchProps, VisuallyHidden, useFocusRing, useSwitch } from "react-aria"; import { useToggleState } from "react-stately"; import cn from "~/utils/cn"; export interface SwitchProps extends AriaSwitchProps { label: string; className?: string; switchClassName?: string; } export default function Switch(props: SwitchProps) { const state = useToggleState(props); const ref = useRef(null); const { focusProps, isFocusVisible } = useFocusRing(); const { inputProps } = useSwitch( { ...props, "aria-label": props.label, }, state, ref, ); return ( ); }