Here are some examples showcasing checkbox components.
Checkboxes are used to select one or more options from a set.
Checkboxes can be styled with different colors using the color
attribute.
.my-2.flex.flex-col.gap-4
= daisy_label(for: "checkbox3") do
= daisy_checkbox(name: "checkbox3", color: "primary", id: "checkbox3")
Primary Checkbox
= daisy_label(for: "checkbox4") do
= daisy_checkbox(name: "checkbox4", color: "secondary", id: "checkbox4")
Secondary Checkbox
= daisy_label(for: "checkbox5") do
= daisy_checkbox(name: "checkbox5", color: "accent", id: "checkbox5")
Accent Checkbox
Checkboxes come in different sizes using the size
attribute.
.my-2.flex.flex-col.gap-4
= daisy_label(for: "standard") do
= daisy_checkbox(name: "standard", id: "standard")
Standard Checkbox
= daisy_label(for: "checked") do
= daisy_checkbox(name: "checked", id: "checked", checked: true)
Checked Checkbox
= daisy_label(for: "disabled", css: "cursor-not-allowed") do
= daisy_checkbox(name: "disabled", id: "disabled", disabled: true)
Disabled Checkbox
= daisy_label(for: "required") do
= daisy_checkbox(name: "required", id: "required", required: true)
Required Checkbox
Checkboxes can be set to an indeterminate state to indicate that the value is neither checked nor unchecked. This is commonly used for "Select All" checkboxes where some items are selected and others are not.
You must set the indeterminate
attribute through JavaScript.
Checkboxes can be disabled using the disabled
attribute.
Checkboxes can be given a custom ID using the id
attribute.
The built-in Form Builder extension provides an even easier way to use checkboxes in your pages by extracting the name and ID attributes from the form object and attributes.
You can also use the Label component directly with checkboxes for fully custom approach.
.my-2.flex.flex-col.gap-4
.flex.items-center.space-x-2
= daisy_checkbox(name: "agree", id: "agree")
= daisy_label(for: "agree", title: "I agree to the terms of service")
.flex.items-center.space-x-2.mt-4
= daisy_checkbox(name: "updates", id: "updates", toggle: true)
= daisy_label(for: "updates") do
Receive product updates