Create Checkbox.js
This commit is contained in:
21
src/components/Checkbox.js
Normal file
21
src/components/Checkbox.js
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user