SaladUI.Switch (SaladUI v1.0.0)

Copy Markdown View Source

Implementation of a switch/toggle component.

A switch is a control that allows users to toggle between checked and not checked states.

Component events

  • :on-checked-changed - Maps the checked-changed event. Fired when the switch is toggled.

Server commands

  • "toggle" - Toggles the switch between checked and unchecked.

Summary

Functions

Renders a switch component.

Functions

switch(assigns)

Renders a switch component.

Props

  • :id - The id to be applied to the input element
  • :name - The name to be applied to the input element
  • :class - Additional CSS classes
  • :value - The current value of the switch
  • :default-value - The default value of the switch
  • :field - Phoenix form field
  • :disabled - Whether the switch is disabled
  • :on-checked-changed - Handler for value change event

Component events

  • :on-checked-changed - Fired when the switch is toggled.

Server commands

  • "toggle" - Toggles the switch between checked and unchecked.

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • class (:string) - Defaults to nil.
  • value (:any) - Defaults to nil.
  • default-value (:any) - Defaults to false.Must be one of true, false, "true", or "false".
  • checked (:boolean)
  • disabled (:boolean) - Defaults to false.
  • on-checked-changed (:any) - Handler for value change event. Defaults to nil.
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:active].
  • Global attributes are accepted.