switch.tsx 561 B

1234567891011121314151617181920212223242526
  1. import classNames from 'classnames'
  2. type SwitchProps = {
  3. onChange: () => void
  4. checked: boolean
  5. disabled?: boolean
  6. }
  7. function Switch({ onChange, checked, disabled = false }: SwitchProps) {
  8. return (
  9. <label className={classNames('switch-input', { disabled })}>
  10. <input
  11. className="invisible-input"
  12. type="checkbox"
  13. role="switch"
  14. autoComplete="off"
  15. onChange={onChange}
  16. checked={checked}
  17. disabled={disabled}
  18. />
  19. <span className="switch" />
  20. </label>
  21. )
  22. }
  23. export default Switch