PhoenixPaper.Checkbox (PhoenixPaper v0.1.0)

Copy Markdown View Source

A Material Design checkbox (pp_checkbox/1).

Accepts either a Phoenix Phoenix.HTML.FormField via field= (idiomatic to_form/2 usage, same as the default core_components.ex input) or plain name/checked attrs.

When paperize is false this renders a bare native <input type="checkbox"> (no hidden-input trick, no custom box) so it never fights a caller's own CSS — class targets that bare input directly in this case (not the wrapping <label>, which keeps its own unconditional layout classes regardless of paperize; see PhoenixPaper.Helpers.toggle_label_classes/1), so e.g. class="size-5" sizes the checkbox itself as expected.

ripple={true} adds the Material ripple effect on click/tap, wired to the small box rather than the whole label — off by default (unlike Button/Fab/ToggleButton), since a checkbox's own instant fill/border-color change already reads as clear feedback on a target this small — see PhoenixPaper.Ripple.

Summary

Functions

pp_checkbox(assigns)

Attributes

  • id (:any) - Defaults to nil.
  • name (:any) - Defaults to nil.
  • value (:any) - Defaults to "true".
  • label (:string) - Defaults to nil.
  • field (Phoenix.HTML.FormField) - Defaults to nil.
  • checked (:boolean) - Defaults to nil.
  • paperize (:boolean) - Defaults to true.
  • ripple (:boolean) - the Material ripple effect on click/tap (default: false) — see PhoenixPaper.Ripple. Defaults to false.
  • disabled (:boolean) - Defaults to false.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["form", "autofocus", "phx-click"].