View Source SaladUI.Switch (SaladUI v1.0.0-beta.1)

Implementation of a switch/toggle component.

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

Summary

Functions

Renders a switch component.

Functions

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

Attributes

  • id (:string) - Defaults to nil.
  • name (:string) - Defaults to nil.
  • class (:string) - Defaults to nil.
  • checked (:boolean) - Defaults to false.
  • 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.