Shadix.Components.Switch (shadix v0.0.1)

Copy Markdown View Source

Switch component translated from shadcn/ui (new-york-v4).

A field-aware boolean control rendered as a native checkbox styled into a pill-shaped switch. Like the checkbox control, it emits a hidden "false" input first so an unchecked switch still submits a value. The thumb is drawn with a before: pseudo-element and translated on checked: — no JavaScript, no phx-* bindings, no Radix data-state behavior.

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

Summary

Functions

switch(assigns)

Attributes

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