Checkbox | jaspr_daisyui_components
jaspr_daisyui_components
pub.dev ↗

Checkbox

Checkboxes are used to select or deselect a value.

Class name Type Description
checkbox Component Checkbox
checkbox-primary Color primary color
checkbox-secondary Color secondary color
checkbox-accent Color accent color
checkbox-neutral Color neutral color
checkbox-success Color success color
checkbox-warning Color warning color
checkbox-info Color info color
checkbox-error Color error color
checkbox-xs Size Extra small size
checkbox-sm Size Small size
checkbox-md Size Medium size
checkbox-lg Size Large size
checkbox-xl Size Extra large size

Checkbox

<input type="checkbox" checked="checked" class="checkbox" />
Checkbox(const [], checked: true);

With fieldset and label

Login options
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
  <legend class="fieldset-legend">Login options</legend>
  <label class="label">
    <input type="checkbox" checked="checked" class="checkbox" />
    Remember me
  </label>
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Login options')]),
    label([Checkbox(const [], checked: true), Component.text('Remember me')], classes: 'label'),
  ],
  classes: 'bg-base-100 border-base-300 rounded-box w-64 border p-4',
);

Sizes

<input type="checkbox" checked="checked" class="checkbox checkbox-xs" />
<input type="checkbox" checked="checked" class="checkbox checkbox-sm" />
<input type="checkbox" checked="checked" class="checkbox checkbox-md" />
<input type="checkbox" checked="checked" class="checkbox checkbox-lg" />
<input type="checkbox" checked="checked" class="checkbox checkbox-xl" />
Component.fragment([
  Checkbox(const [], size: CheckboxSize.xs, checked: true),
  Checkbox(const [], size: CheckboxSize.sm, checked: true),
  Checkbox(const [], size: CheckboxSize.md, checked: true),
  Checkbox(const [], size: CheckboxSize.lg, checked: true),
  Checkbox(const [], size: CheckboxSize.xl, checked: true),
]);

Colors

<input type="checkbox" checked="checked" class="checkbox checkbox-primary" />
<input type="checkbox" checked="checked" class="checkbox checkbox-secondary" />
<input type="checkbox" checked="checked" class="checkbox checkbox-accent" />
<input type="checkbox" checked="checked" class="checkbox checkbox-neutral" />
<input type="checkbox" checked="checked" class="checkbox checkbox-info" />
<input type="checkbox" checked="checked" class="checkbox checkbox-success" />
<input type="checkbox" checked="checked" class="checkbox checkbox-warning" />
<input type="checkbox" checked="checked" class="checkbox checkbox-error" />
Component.fragment([
  Checkbox(const [], color: CheckboxColor.primary, checked: true),
  Checkbox(const [], color: CheckboxColor.secondary, checked: true),
  Checkbox(const [], color: CheckboxColor.accent, checked: true),
  Checkbox(const [], color: CheckboxColor.neutral, checked: true),
  Checkbox(const [], color: CheckboxColor.info, checked: true),
  Checkbox(const [], color: CheckboxColor.success, checked: true),
  Checkbox(const [], color: CheckboxColor.warning, checked: true),
  Checkbox(const [], color: CheckboxColor.error, checked: true),
]);

Disabled

<input type="checkbox" class="checkbox" disabled="" />
<input type="checkbox" class="checkbox" disabled="" checked="checked" />
Component.fragment([
  Checkbox(const [], disabled: true),
  Checkbox(const [], checked: true, disabled: true),
]);

Indeterminate

<!-- You can make a checkbox indeterminate using JS -->
<script>document.getElementById("my-checkbox").indeterminate = true</script>
<input type="checkbox" class="checkbox" id="my-checkbox" />
Component.fragment([
  RawText(r'''<script>
  document.getElementById("my-checkbox").indeterminate = true
</script>'''),
  Checkbox(const [], id: 'my-checkbox'),
]);

Checkbox with custom colors

<input type="checkbox" checked="checked" class="checkbox border-indigo-600 bg-indigo-500 checked:border-orange-500 checked:bg-orange-400 checked:text-orange-800" />
Checkbox(
  const [],
  classes: 'border-indigo-600 bg-indigo-500 checked:border-orange-500 checked:bg-orange-400 checked:text-orange-800',
  checked: true,
);