Checkbox
v0.0.10
mix mishka.ui.gen.headless checkbox
Overview of the Phoenix and LiveView Headless Checkbox Component
The Mishka Chelekom Headless Checkbox ships zero opinionated styling - only the semantic markup, full WAI-ARIA wiring, a hidden native checkbox input for form submission, and paired-presence state (data-checked/data-unchecked). Every part - root, input, indicator and label - is addressable through a *_class attribute, so you style it entirely with your own Tailwind classes while the accessibility and behavior keep working underneath.
The root takes class. input_class, indicator_class and label_class reach the hidden native input that carries the form value, the indicator box and the label. The input is visually hidden and skipped by the Tab key, so input_class rarely changes how it looks: use it to give the native input a class of your own, for a selector or a script.
Base UI Checkbox example (Phoenix headless)
Base UI Checkbox example (Phoenix headless)
<.checkbox
id="baseui-checkbox-hero"
checked
class="flex items-center gap-2 text-sm font-normal text-neutral-950 dark:text-white focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 dark:focus-visible:outline-white"
indicator_class="group flex size-4 shrink-0 items-center justify-center border rounded-none p-0 border-neutral-950 bg-white text-white dark:border-white dark:bg-neutral-950 dark:text-neutral-950 data-[checked]:bg-neutral-950 data-[checked]:text-white dark:data-[checked]:bg-white dark:data-[checked]:text-neutral-950"
>
<:indicator>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
stroke="currentColor"
class="block group-data-[unchecked]:hidden"
>
<path d="m2.5 8.5 4 4 7-9" />
</svg>
</:indicator>
Enable notifications
</.checkbox>Parts & data attributes
Each part carries a stable data-part and a structural chelekom-checkbox__* class you can target, plus paired-presence state for checked/unchecked/indeterminate.
| Part | data-part | State / ARIA | Purpose |
|---|---|---|---|
| Root | (button) | role="checkbox", aria-checked, aria-readonly, aria-required, data-checked, data-unchecked, data-indeterminate, data-disabled, data-readonly, data-required, data-parent | The clickable control itself. Takes class. |
| Input | input | aria-hidden | Hidden native checkbox that syncs form submission. Takes input_class. |
| Indicator | indicator | aria-hidden, data-checked, data-unchecked, data-indeterminate | Visual box for your check icon; mirrors the root's state. Takes indicator_class. |
| Label | label | - | Wraps the checkbox's inner content. Takes label_class. |
Accessibility
Follows the WAI-ARIA Checkbox pattern: the root exposes role="checkbox" with a live aria-checked (true/false/mixed), and Space or Enter toggles the checked state. Mark a checkbox parent and wrap a set of checkboxes in a CheckboxGroup hook to get a tristate select-all that reflects all/none/some of its children.
Attributes
| Name | Type | Default | Values | Required | Description |
|---|---|---|---|---|---|
id
|
string
| — | — | Yes | Unique id (anchors the control) |
name
|
string
| — | — | No | Name for the hidden form input |
checked
|
boolean
|
false
| — | No | Initial/controlled checked state |
indeterminate
|
boolean
|
false
| — | No | Mixed state (aria-checked="mixed") |
value
|
string
|
true
| — | No | Submitted value when checked |
disabled
|
boolean
|
false
| — | No | Disable interaction |
readonly
|
boolean
|
false
| — | No | Block toggling but stay focusable |
required
|
boolean
|
false
| — | No | Mark as required for native validation |
parent
|
boolean
|
false
| — | No | Tristate "select all" parent of a CheckboxGroup |
on_change
|
string
| — | — | No | LiveView event pushed on toggle ({checked}) |
class
|
any
| — | — | No | Extra classes for the root |
indicator_class
|
any
| — | — | No | Extra classes for the indicator box |
label_class
|
any
| — | — | No | Extra classes for the label |
input_class
|
any
| — | — | No | — |
rest
|
global
| — | — | No | — |
Slots
| Name | Required | Description |
|---|---|---|
indicator
| No | Visual content of the indicator box (e.g. a check svg) |
inner_block
| Yes | The checkbox label |
Options
Each option takes one or more of its values, separated by commas.
| Option | Values |
|---|---|
--type
|
checkbox
|
--module
| A module name of your own |
What it generates
mix mishka.ui.gen.headless checkbox