The Switcher field puts Elementor’s familiar yes/no toggle into a custom widget. One flick in the panel and a badge appears, a layout tightens, or a whole block of markup switches off. Inside the Master Addons Widget Builder, the Switcher is the standard way to make any part of a widget optional.
Its value is deliberately simple: a string like yes when the toggle is on, an empty string when it is off. That maps straight onto template conditionals. In practice, almost every Switcher ends up wrapped in an {% if %} block or driving the Conditions of other controls.
What the Switcher field does #
- Renders Elementor’s on/off toggle in the widget panel, with your own on/off labels.
- Returns a configurable string (default
yes) when on, and an empty string when off. - Drives
{% if %}blocks in the template, so markup renders only when the toggle is on. - Switches CSS classes inline, for example
class="card {% if compact_mode %}is-compact{% endif %}". - Acts as the usual driver for Conditions on other fields, showing or hiding whole groups of controls.
Building your first widget? Start with the Widget Builder overview, then come back here.
Before you start #
- WordPress with Elementor installed and active.
- Master Addons for Elementor installed and active. New to the plugin? See the installation guide.
- A custom widget open in the Widget Builder editor. Our example is a pricing card widget with a Switcher named
show_badgethat reveals a “Popular” ribbon on the card.
How to add a Switcher field #
Drag the Switcher field from the fields panel into a section under the Content or Style tab. Its options open on the left as soon as it lands.
Switcher field options explained #
- Label: the text shown next to the toggle in Elementor, for example “Show Badge”.
- Name: the unique identifier your templates refer to. Letters, numbers, and underscores only, for example
show_badge. - Label On / Label Off: the short texts on the toggle itself, “Yes” and “No” by default.
- Return Value: the string the field holds while on,
yesby default. Change it when your template or script expects a specific string. - Default: set it to the Return Value to start the toggle on; leave it empty to start off.
Note that Default and Return Value have to match exactly for the toggle to start on. If you change the Return Value to enabled but leave Default at yes, the widget drops in with the toggle off and no error tells you why.
Connect the Switcher with an {% if %} block #
The Switcher is a token field, but you rarely print its token on its own. Off means empty string, and an empty string is falsy in template logic, so the natural pattern is a conditional in the HTML panel:
{% if show_badge %}
<span class="pc-badge">Popular</span>
{% endif %}Toggle on, the badge renders. Toggle off, the markup disappears entirely, leaving no empty wrapper behind. The same pattern switches classes without extra markup:
<article class="pc-card {% if compact_mode %}is-compact{% endif %}">The Switcher’s other job is driving Conditions. Any field in the widget can be set to appear only when the Switcher is on, so toggling “Show Badge” can also reveal a Badge Text field and a badge color control in the panel. That keeps the panel short until the option is actually in use.
Watch out: if you compare the value explicitly, compare against the Return Value string, not the label. {% if show_badge == 'yes' %} matches the default Return Value; {% if show_badge == 'Yes' %} never matches, because “Yes” is only the toggle’s display text. Bare truthiness, {% if show_badge %}, sidesteps the issue.
Use the Switcher control in Elementor #
Add your custom widget to a page in Elementor (reload the editor if the page was already open). The Switcher shows as the standard Elementor toggle under your label. Click it and the preview updates immediately; any fields conditioned on it appear or disappear in the panel at the same time.
Common use cases #
- Optional badges and ribbons on cards, wrapped in an
{% if %}block. - Layout variants like a compact mode, applied as a modifier class.
- Show/hide sections such as a footer note, an icon, or a secondary button.
- Feature switches for scripts, where the JS panel reads the value to enable autoplay or animation.
- Panel gatekeeping, revealing a group of related controls only when their feature is on.
Tips for working with the Switcher field #
- Test truthiness, not labels.
{% if show_badge %}is all most templates need; the on state is a non-empty string and the off state is empty. - Wrap the whole optional block. Put the
{% if %}around the complete markup, wrapper included, so an off toggle leaves no empty elements to break spacing. - Default deliberately. Start the toggle on (Default = Return Value) for features most sites want, off for extras.
- Pair it with Conditions. A Switcher plus two or three conditioned fields reads far better in the panel than five always-visible controls.
- Name it as a question the toggle answers.
show_badgeandcompact_moderead naturally inside{% if %}blocks.
Frequently Asked Questions #
What is the Switcher field in the Master Addons Widget Builder?
The Switcher field adds Elementor’s on/off toggle to a custom widget. When on, it holds its Return Value string (yes by default); when off, it holds an empty string. Templates typically wrap optional markup in {% if field_name %} ... {% endif %} to react to it.
What value does the Switcher actually store?
A string. On means the Return Value you configured, off means an empty string. There is no true/false boolean, which is why explicit comparisons must match the Return Value exactly.
How do I show markup only when the toggle is on?
Wrap it in a conditional in the HTML panel: {% if show_badge %}<span class="badge">Popular</span>{% endif %}. The block renders nothing at all while the toggle is off.
Can a Switcher show or hide other fields in the panel?
Yes, and it is the most common driver for that. Set the Conditions on any other field to require the Switcher’s value, and those controls appear in Elementor only while the toggle is on.
Why does my {% if show_badge == ‘Yes’ %} check never pass?
Because “Yes” is the toggle’s Label On text, not its value. The stored value is the Return Value, yes in lowercase by default. Compare against that, or simply use {% if show_badge %}.
Can I change what the field returns when on?
Yes, through the Return Value option. This is useful when the JS panel expects a specific flag string, or when you print the value directly into a data attribute.
Wrapping up #
The Widget Builder Switcher field is the smallest control with the widest reach: one toggle can add markup, swap classes, and reshape the panel through Conditions all at once. Combine it with a Number field for tunable features or a Repeater field whose optional extras it reveals. Explore the rest of the Master Addons widgets and extensions, and see the pricing page for what each plan includes.
