Switch

Renders a switch component.

Read more Read less

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.
Attribute Type Documentation Default Value
id :string
name :string
class :string
value :any
default-value :any false
checked :boolean
disabled :boolean false
on-checked-changed :any

Handler for value change event

field %FormField{}

a form field struct retrieved from the form, for example: @form[:active]

rest :global