Files
MattrixwvReactComponents/lib/component/input/switch/ButtonSwitch.tsx

36 lines
576 B
TypeScript

import type { MattrixwvButtonSwitchProps } from "$/types/InputTypes";
import { Switch } from "@headlessui/react";
export default function ButtonSwitch({
id,
className,
name,
value,
defaultChecked,
checked,
onChange,
disabled,
onNode,
offNode
}: MattrixwvButtonSwitchProps){
return (
<Switch
id={id}
className={className}
name={name}
value={value}
defaultChecked={defaultChecked}
checked={checked}
onChange={onChange}
disabled={disabled}
>
{({ checked }) => (
<>
{checked ? onNode : offNode}
</>
)}
</Switch>
);
}