Skip to main content

How to Add a Toggle in Power Apps

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A toggle is an on/off switch with a label beside it. In Power Apps, the modern Toggle control starts on or off from a value you choose, and tells your formulas which way it's set through its Checked property: true when on, false when off.

The example below is an Active switch on a form that adds and edits departments: a new department starts active, and an existing one shows its saved value.

Prerequisites​

Step 1: Insert the Toggle​

Select where the toggle should go: a container, or the screen. Open the Insert pane and search for toggle. It finds two:

The Insert pane searched for toggle, listing Toggle under Input and Toggle under Classic

Select the one under Input: that's the modern control. The one under Classic is the older toggle.

In the example, I had the form's container selected, and the toggle went in at the end of it, under the Save button, as Toggle1:

Power Apps Studio with Toggle1 selected under the Save button of the Edit department form, switched off with the text Label beside it, and the Properties pane showing Default Off, Label Label, Label position After, Width 113 and Height 35

Its starting values:

PropertyValue
Defaultfalse: off
Label"Label"
Label positionAfter: the text after the switch
Width, Height113, 35

Rename it with the tgl prefix, such as tglActiveED (Power Apps Naming Conventions). If it landed in the wrong place in a container, move it with Reorder (How to Reorder Controls in a Container in Power Apps).

Step 2: Set What It Says​

Label is the text beside the switch. Make it the setting the switch turns on, here "Active":

The formula bar with the Label property of the toggle set to "Active", and the Edit department form on the canvas with the Active toggle selected

AccessibleLabel is what screen readers announce. Say what on means, not just the label:

tglActiveED → AccessibleLabel
"Active: staff can choose this department when they log overtime"

Step 3: Set How It Starts​

Default decides whether the toggle starts on or off: true, false, or a formula. The example form adds new departments and edits existing ones, so a new department starts active and an existing one shows its saved value:

tglActiveED → Default
If(IsBlank(locDepartment), true, locDepartment.IsActive)

locDepartment is the department being edited, and blank for a new one.

Microsoft's page for the control calls this starting value Checked: The initial value of a control before it's changed by the user. In Studio, the toggle (ModernToggle 1.0.1 in its code) lists it as Default, on the Advanced tab too, together with OnCheck and OnUncheck:

The Advanced tab of the toggle's Properties pane, with OnCheck false and OnUncheck false under Action, and AccessibleLabel, ContentLanguage, Default false, Label "Label" and Tooltip under Data

Step 4: Use Its Value​

In other formulas, tglActiveED.Checked is true while the toggle is on and false while it's off. The example's Save button reads it when it's selected, and stores it in a SharePoint Yes/No column (How to Save a Toggle to a SharePoint Yes/No Column in Power Apps).

The form in Preview, with the toggle switched off:

The Add department screen in Preview with Name Day Surgery, Approvers Olivia Bennett and Daniel Brooks, the Active toggle switched off, and a green Save button

To run something the moment it's switched, use OnCheck (when it changes to on) and OnUncheck (when it changes to off). For a form that saves with a button, as here, they aren't needed: Save reads Checked when it's selected.

Common Mistakes​

MistakeWhat happensDo this instead
Inserting the toggle under ClassicYou get the older controlUse Toggle under Input
Reading Default in another formulaYou get the starting value, not what the user setRead .Checked
Leaving Label as "Label"The switch says LabelName the setting it turns on
An empty AccessibleLabelScreen readers don't say what the switch is forDescribe what on means

Troubleshooting​

SymptomLikely causeFix
No Checked property in the listChecked is what the toggle returns; it's set with DefaultSet Default, read .Checked
The toggle shows the last value when the screen opens againControls keep their value until resetReset(tglActiveED) when the screen opens (How to Reset a Control to Its Default Value in Power Apps with Reset)

FAQ​

Why does Microsoft's page say Checked when Studio shows Default?​

The page describes Checked as the starting value. Studio's version of the control has Default for that, and Checked is the value you read. Use what Studio shows; formulas with .Checked worked as expected in the example.

Can the label go before the switch?​

Yes. Label position has Before and After. In formulas, Studio writes it as ToggleLabelPosition.After.

Conclusion​

Insert Toggle from Input, set Label, AccessibleLabel and Default, and read Checked wherever you need to know whether it's on.

Additional Resources​