Switch
Last updated
Was this helpful?
Last updated
Was this helpful?
The Switch component in Lowcoder provides a user-friendly toggle interface, enabling users to switch between two states, such as "on" and "off" or "enabled" and "disabled." This component is ideal for settings, preferences, and binary choices within applications.
Binary Toggle: Offers a simple interface for toggling between two states.
Customizable Labels: Allows setting custom labels for both "on" and "off" states to enhance clarity.
Dynamic Binding: Supports binding to variables or data sources for real-time state management.
Event Handling: Triggers actions based on state changes, facilitating interactive application behavior.
Styling Options: Provides customisation of appearance to align with application design.
Default State: Set the initial state of the switch (on/off) upon component load.
Disabled State: Disable the switch to prevent user interaction when necessary.
Labels: Define custom text labels for both states to provide context.
Styling: Customize dimensions, colors, and other visual aspects to match your application's theme.
Event Handlers: Define actions to be executed upon state changes, such as updating data or triggering other components.
Data Binding: Use Lowcoder's data binding syntax ({{ }}
) to connect the switch state to variables or data sources.
Event Handling: Implement event handlers to perform actions when the switch state changes, such as updating a database or triggering notifications.
Combining with Other Components: Integrate the Switch component with forms, settings panels, or other interactive elements to enhance user experience.
On Component Playground, you can interact with the Switch component and explore it's Properties, Events and Methods. Play with different Styling properties to see the effect on the Switch component.
In the Auto-Docs of Switch component, we have shown how to use different properties of the Switch component. It also includes the Styling properties of the Switch component.
These properties are accessible in {{ }} notations, as well as in JavaScript Queries.
value
Boolean
Returns True or False based on whether the Switch component is On or not
disabled
Boolean
Returns True or False based on whether the Switch component is disabled or not
hidden
Boolean
Returns True or False based on whether the Switch component is hidden or not
Events give you the ability to trigger further actions (with Event-Handlers).
Change
Triggers, when anything Changes on the Switch component
On
Tiggers, when Switch component is Turned On.
Off
Tiggers, when Switch component is Turned Off.
You have the capability to engage with components via their respective methods, which can be accessed by their designated names within any segment where JavaScript is utilized. Additionally, these components can be activated through the 'Control Component' action, which is triggered in response to specific events.
setValue() :
switch1.setValue() method sets the Switch component's Value property, which gets shown in the Switch component.
clearValue() :
switch1.clearValue() clears the Switch component's Value property and empties the value from the Switch component.
resetValue() :
switch1.resetValue() method resets the Switch component's value property to the default value of the Switch component.
setDefaultValue() :
switch1.setDefaultValue() method sets the Switch component's Default value, which gets shown in the Switch component as default.
clearDefaultValue() :
switch1.clearDefaultValue() clears the Switch component's Default value and empties the value from the Switch component.
resetDefaultValue() :
switch1.resetDefaultValue() method resets the Switch component's Default value to the default value of the Switch component.
Feature Toggles: Allow users to enable or disable specific features within the application.
Preference Settings: Enable users to set preferences, such as dark mode or notifications.
Access Controls: Manage user access to certain functionalities or sections of the application.
Form Inputs: Collect binary responses in forms or surveys.