Qwik checkbox - Flowbite
The checkbox component can be used to receive one or more selected options from the user in the form of a square box available in multiple styles, sizes, colors, and variants.
To use the range component, you need to import it from flowbite-qwik :
import { Checkbox } from "flowbite-qwik"
Checkbox example
Use this default example of a checkbox element in a checked and unchecked state.
import { component$ } from '@builder.io/qwik'
import { Checkbox } from 'flowbite-qwik'
export default component$(() => {
  return (
    <>
      <div class="p-3">
        <Checkbox>Checkbox</Checkbox>
      </div>
    </>
  )
})
Disabled state
This example can be used for the disabled state of the checkbox component by applying the disabled attribute to the input element.
import { component$ } from '@builder.io/qwik'
import { Checkbox } from 'flowbite-qwik'
export default component$(() => {
  return (
    <>
      <div class="p-3">
        <Checkbox disabled>Disable</Checkbox>
      </div>
    </>
  )
})
Checked state
This example can be used for the checked state of the checkbox component.
import { component$, useSignal } from '@builder.io/qwik'
import { Checkbox } from 'flowbite-qwik'
export default component$(() => {
  const val = useSignal(true)
  return (
    <div class="flex flex-col gap-3">
      Reactive checked value : {String(val.value)}
      <Checkbox bind:checked={val}>Checked</Checkbox>
    </div>
  )
})
With link
Use this example if you want to add an anchor link inside the label of the checkbox component.
import { component$, useSignal } from '@builder.io/qwik'
import { Checkbox } from 'flowbite-qwik'
export default component$(() => {
  const val = useSignal(false)
  return (
    <>
      <div class="p-3">
        <Checkbox bind:checked={val}>
          <a href="#" class="text-blue-500 underline">
            I agree with terms and conditions.
          </a>
        </Checkbox>
      </div>
    </>
  )
})
On change event
This example can be used for the onchange event of the checkbox component.
import { component$, useSignal } from '@builder.io/qwik'
import { Checkbox } from 'flowbite-qwik'
export default component$(() => {
  const val = useSignal(false)
  return (
    <div class="flex flex-row gap-6">
      <div class="flex flex-col gap-3">
        With no reactive checked value
        <Checkbox
          value="case1"
          onChange$={(state: boolean, value: string) => {
            alert(`Checkbox state changed to ${state} with value ${value}`)
          }}
        >
          Checkbox
        </Checkbox>
      </div>
      <div class="flex flex-col gap-3">
        With reactive checked value : {String(val.value)}
        <Checkbox
          value="case2"
          bind:checked={val}
          onChange$={(state: boolean, value: string) => {
            alert(`Checkbox state changed to ${state} with value ${value}`)
          }}
        >
          Change state
        </Checkbox>
      </div>
    </div>
  )
})
Colors
This example can be used for the color of the checkbox component by applying the color attribute to the input element.
import { component$, useSignal } from '@builder.io/qwik'
import { Checkbox, FlowbiteTheme } from 'flowbite-qwik'
export default component$(() => {
  const val = useSignal(true)
  return (
    <>
      <div class="flex flex-wrap gap-3 p-3">
        {(['blue', 'green', 'red', 'pink', 'purple'] as FlowbiteTheme[]).map((color) => (
          <Checkbox bind:checked={val} color={color}>
            {color}
          </Checkbox>
        ))}
      </div>
    </>
  )
})