Skip to main content

switch

Switch

from dara.components.common.switch import Switch

class Switch(FormComponent)

Switch

A component that creates a switch. Takes a boolean value that determines whether the switch is on or off.

A Switch component is created via:

from dara.core import Variable
from dara.components.common import Switch

value_var = Variable(default=True)

Switch(value=value_var)

Arguments:

  • value: Boolean Variable instance recording the component's state
  • onchange: Action triggered when the component switches states.
  • id: the key to be used if this component is within a form

Attributes

  • value: Optional[Union[Variable[bool], UrlVariable[bool]]]
  • onchange: Optional[Action]
  • id: Optional[str]