@eviljs/reactx
Version:
Awesome React UI Widgets
16 lines (15 loc) • 691 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { classes } from '@eviljs/react/classes';
import { asBooleanString } from '@eviljs/web/aria';
export function Switch(props) {
const { className, checked, children, onChange, ...otherProps } = props;
return (_jsx("button", { type: "button", ...otherProps, className: classes('Switch-5a04 std-switch', className, {
'std-knob': !children,
}), role: "switch", "aria-checked": asBooleanString(checked ?? false), onClick: event => {
props?.onClick?.(event);
if (props.disabled) {
return;
}
onChange?.(!checked);
}, children: children }));
}