PhoenixPaper.Switch (PhoenixPaper v0.1.0)

Copy Markdown View Source

A Material Design switch (pp_switch/1) — an on/off toggle, structured like PhoenixPaper.Checkbox but rendered as a sliding track/thumb.

Accepts either a Phoenix Phoenix.HTML.FormField via field= or plain name/checked attrs.

When paperize is false this renders a bare native <input type="checkbox"> (no hidden-input trick, no custom track/thumb) — class targets that bare input directly in this case, same as PhoenixPaper.Checkbox.

Summary

Functions

pp_switch(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 — off whenever paperize is false, see PhoenixPaper.Ripple. Defaults to true.
  • disabled (:boolean) - Defaults to false.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["form", "autofocus", "phx-click"].