import clsx from "clsx"; import { forwardRef } from "react"; import type { Size } from "@camome/system"; import { UnstyledInput } from "../UnstyledInput"; import styles from "./styles.module.scss"; export type SwitchProps = { on?: React.ReactNode; off?: React.ReactNode; size?: Size; } & Omit; // Reference: https://www.w3.org/WAI/ARIA/apg/patterns/switch/ export const Switch = forwardRef( ({ on, off, size = "md", style, className, ...props }, ref) => { return (
{/* aria-hidden: https://www.w3.org/WAI/ARIA/apg/example-index/switch/switch-checkbox.html#:~:text=NOTE%3A%20To%20prevent%20redundant%20announcement%20of%20the%20state%20by%20screen%20readers%2C%20the%20text%20indicators%20of%20state%20are%20hidden%20from%20assistive%20technologies%20with%20aria%2Dhidden. */}
{on}
{off}
); } ); Switch.displayName = "Switch";