import { ComponentChildren, FunctionalComponent } from 'preact'; import { useState } from 'preact/hooks'; import { HTMLProps } from 'react'; import { CustomCheckboxContainer, CustomCheckboxInput, CustomCheckboxInputProps, } from '@reach/checkbox'; import '@reach/checkbox/styles.css'; export type SwitchProps = HTMLProps & { checked?: boolean; onChange: (checked: boolean) => void; children: ComponentChildren; }; export const Switch: FunctionalComponent = ( props: SwitchProps ) => { const [checkedState, setChecked] = useState(props.checked || false); const checked = props.checked ?? checkedState; return ( ); };