Create Checkbox.js

This commit is contained in:
Natxo
2026-03-31 12:13:12 +02:00
committed by GitHub
parent 0e849ea03a
commit 7c6ee5394c

View File

@@ -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;
};