Toggle Button in Canvas App

A toggle button in a Canvas app is a graphical user interface (GUI) element that allows a user to switch a setting or state between two options, usually on and off. When the user clicks on the button, the state of the setting changes, and the button’s appearance may also change to indicate the new state.

To create a toggle button in a Canvas app, you can follow these steps:

  1. Add a button control to your Canvas app.
  2. Set the button’s Text property to the label you want to appear on the button, such as “On” or “Off.”
  3. Set the button’s OnSelect property to a formula that will toggle the button’s state. For example, you could use the following formula to toggle a variable named “IsOn”:
    UpdateContext({IsOn: !IsOn})
  4. Set the button’s Fill property to a color that represents the button’s current state. For example, you could use the following formula to fill the button with green if the “IsOn” variable is true and red if it is false:
    If(IsOn, Green, Red)
  5. You can also add additional visual cues to indicate the button’s state, such as changing the button’s text color or adding an icon.

By following these steps, you can create a toggle button in your Canvas app that allows users to switch a setting or state between two options.


Posted

in

by

Tags: