Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
632 B
TypeScript
25 lines
632 B
TypeScript
import styles from './ToggleSwitch.module.css'
|
|
|
|
interface ToggleSwitchProps {
|
|
checked: boolean
|
|
onChange: (checked: boolean) => void
|
|
disabled?: boolean
|
|
ariaLabel?: string
|
|
}
|
|
|
|
export function ToggleSwitch({ checked, onChange, disabled, ariaLabel }: ToggleSwitchProps) {
|
|
return (
|
|
<button
|
|
type="button"
|
|
role="switch"
|
|
aria-checked={checked}
|
|
aria-label={ariaLabel ?? (checked ? 'Enabled' : 'Disabled')}
|
|
className={`${styles.switch} ${checked ? styles.on : ''}`}
|
|
onClick={() => onChange(!checked)}
|
|
disabled={disabled}
|
|
>
|
|
<span className={styles.thumb} />
|
|
</button>
|
|
)
|
|
}
|