diff --git a/src/components/Checkbox.js b/src/components/Checkbox.js new file mode 100644 index 0000000..863cba4 --- /dev/null +++ b/src/components/Checkbox.js @@ -0,0 +1,21 @@ +import { $html } from "sigpro"; +import { val } from "../core/utils.js"; + +/** CHECKBOX */ +export const Checkbox = (props) => { + const { value, tooltip, toggle, label, ...rest } = props; + + const checkEl = $html("input", { + ...rest, + type: "checkbox", + class: () => (val(toggle) ? "toggle" : "checkbox"), + checked: value + }); + + const layout = $html("label", { class: "label cursor-pointer justify-start gap-3" }, [ + checkEl, + label ? $html("span", { class: "label-text" }, label) : null, + ]); + + return tooltip ? $html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout; +};