Shadix.Components.Checkbox (shadix v0.0.1)

Copy Markdown View Source

Checkbox component adapted from shadcn/ui (new-york-v4).

Renders a native <input type="checkbox"> (with a preceding hidden "false" input so an unchecked box still submits a value) and is field-aware: it derives its id, name, value, and errors from a Phoenix.HTML.FormField.

The box is the appearance-none input; the check mark is a sibling <svg> overlay shown via peer-checked:visible. It uses text-primary-foreground (via currentColor) so the check contrasts correctly in both light and dark mode — unlike a fixed-colour background-image. No JavaScript, no Radix.

Caller-supplied class is appended last (to the input); Tailwind cascade layers ensure it wins over the defaults.

Summary

Functions

checkbox(assigns)

Attributes

  • field (Phoenix.HTML.FormField) (required)
  • class (:string) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["disabled", "required", "readonly", "autofocus"].