Skip to main content

Modes and feedback styling

Modes let one element show different appearances for different states. Use them for an active source, a light that is on, a selected room, or an equipment status indicator.

The element's base properties are its Default appearance. Each added mode overrides only the properties that need to change. A two-state control therefore needs Default plus one mode, rather than separate Off and On elements.

This guide covers AVstudio Editor NG 27.0.29. The illustrated demonstration changes a local variable without connecting to equipment.

In 27.0.4 and later, a Crestron feedback token can drive activeModeIndex directly: !crestron:type=boolean;name=101! selects Default for false and the first added mode for true. A string join can select a named mode. Test with Crestron emulation in the running preview; the design canvas has no live feedback.

Default properties and mode overrides​

PartWhat it containsLight-control example
DefaultThe normal element propertiesGray background and Light OFF label
ModeA named set of changed propertiesBlue background and Light ON label
Active mode valueA literal or a dynamic value that selects the appearance$lightOn$ resolves to false or true
ActionsBehavior when the element is usedA command configured separately from the appearance

Mode properties are merged over the base properties. Settings not overridden by the active mode keep their base values. For example, an On mode can change the label and background while preserving the button's dimensions and typography.

Mode overrides can include text, colors, background, border, icons, sizing, and positioning where those properties are supported by the element. A mode cannot contain another modes array.

Keep the touch area consistent when only status is changing. Moving or resizing a control as feedback arrives can make it harder to operate.

Make an on/off indicator​

1. Create the driving variable​

Run Open Variables and add a boolean global variable named lightOn, with a default value of false.

For a reusable subpage whose state should differ between instances, use a page parameter instead. Define it on the target page and reference it as %lightOn%. See Variables and parameters and Subpages.

2. Configure Default​

  1. Add a Button and give it a name such as LightStatus.
  2. Open Element Properties.
  3. Set the default label to Light OFF.
  4. Set a dark gray background, readable text color, and a suitable touch area.
  5. Keep these off-state settings in the element's base properties.

NG mode demonstration with a gray Light OFF indicator and separate Set OFF and Set ON test buttons

Demo captured in NG 0.1.54. Default appearance: the local demonstration variable is false. The test buttons on the right change that variable; they are not equipment commands.

3. Add the On mode​

  1. Click Create element mode when the element has no modes, or Add mode when a mode already exists.
  2. Name the mode On.
  3. While editing that mode, change the label to Light ON and the background to blue.
  4. Leave dimensions and other unchanged settings in Default.
  5. Keep the mode using the base actions unless it specifically needs different behavior.

4. Connect the active mode value​

In Element Properties, find Mode selector by index or name. Bind this field to the global variable lightOn; a variable binding appears with the blue var control and the variable name beside it. In the page file, this sets activeModeIndex to $lightOn$. The runtime resolves the variable and selects:

  • false → Default.
  • true → the first added mode, On.

Creating a mode does not automatically bind it to device state. The active mode value must be set to the intended variable, parameter, or literal selector.

Preview the modes inside VS Code​

Select the button on the visual canvas and open Element Properties. Below the selector, Mode preview (editor only) lists 0 Default and the added modes. This lets you inspect each appearance while developing the page.

VS Code Element Properties showing the variable binding and Default mode selected beside the gray Light OFF button

The development environment with 0 Default selected. The sample project calls its boolean variable docsLightOn; it serves the same purpose as lightOn in the instructions above. Width and Height remain 300 × 72 pixels.

  1. Select 0 Default to inspect the base appearance.
  2. Select 1 On to show the On appearance on the canvas.
  3. Expand Appearance or Content to work on the selected appearance. Check the selected mode before changing a property.
  4. Return to 0 Default when you want to work on the base settings again.

VS Code showing On selected in Mode preview and the same button rendered blue with the Light ON label

Selecting 1 On changes the canvas to the blue Light ON appearance. The selection label above the button includes [Mode: 1]. The element name remains Light OFF in this sample: its name identifies the element, while its displayed text changes with the mode.

The editor-only preview is a design aid. Selecting a radio button here does not prove that runtime feedback selects the correct mode. Keep Mode selector by index or name bound to the intended value, then test that binding in Live Preview as described below.

5. Test both directions​

For a local test, add separate Set OFF and Set ON buttons. Configure each with an onPress action that sets the boolean variable to false or true. Then open Live Preview and press both buttons.

In the action editor, name the action Set light test state on, choose onPress, select the variable action and lightOn, and set its boolean value to true. Configure the Set OFF button the same way with false.

NG mode demonstration after setting the local boolean variable to true, with a blue Light ON indicator

The same indicator after Set ON. Only its label and background change; its size and position remain the same. Returning the variable to false restores Default.

How selection works​

Mode indexes are one-based. Default is the base element, not the first entry in the modes array.

Active mode valueSelected appearance
Unset, null, 0, false, or an empty stringDefault
String "0" or "false"Default
1 or string "1"First added mode
2 through the number of modesCorresponding added mode
true or string "true"First added mode
Mode nameCase-insensitive name match
Unknown mode nameDefault
$variable$ or %parameter%Resolve the value first, then apply the selection rules

Use a boolean for two appearances, a number when the integration supplies a defined state index, or names when states are easier to understand as labels such as Selected and Unavailable.

If you reorder modes, review every numeric selector: 1 now means the first mode in the new order. If you rename a mode, update values that select it by name.

Example: Default, Selected, and Unavailable​

A source button can have three appearances:

StateSelectorExample appearance
Ready0Gray background, Ready label
Selected1 or SelectedBlue background, Selected label
Unavailable2 or UnavailableAmber background, Unavailable label

Three NG buttons showing Default Ready, Selected, and Unavailable appearances

Three instances with the same mode definitions are shown side by side for comparison. A working source button would select one of these appearances at a time.

To drive this from a string global variable, create sourceState and add two modes:

In Element Properties, set the Default text to Ready with a dark background. Add a Selected mode with blue background and an Unavailable mode with brown background. Keep the base actions unless a mode needs its own behavior. Attach the Mode selector to the global variable sourceState.

Create sourceState before using the token. The values Selected and Unavailable select the matching modes; an empty value selects Default.

An Unavailable appearance is a visual state. Changing its color and text alone does not disable interaction or suppress actions. Configure the intended behavior separately and test it.

Connect modes to device feedback​

Use the device's reported state to drive the variable or parameter that selects the mode.

  1. Configure the project's connector and confirm it receives the required state.
  2. Bind the driving variable to the corresponding signal, topic, or datapoint using the variable's external-binding settings.
  3. Ensure the resulting value matches the selector: boolean, numeric index, or mode name.
  4. Configure the control's outgoing command separately.
  5. Change the device state from another controller and verify that the interface follows it.

For a light, the press action requests a change; the feedback value reports whether the light is actually on. A command being sent does not prove the equipment reached that state.

Use the local Set ON/OFF buttons only to verify the visual setup before integration. Once testing actual equipment, confirm that the reported device value drives the appearance rather than a local test action.

A mode does not automatically create an offline, pending, or error state. If the interface needs those states, define them and provide a value that selects each one.

Actions in modes​

By default, the element's base actions continue to run when a mode is active. A color or label change does not create a new action set.

Mode configurationAction behavior
isModeHasOwnActions: falseContinue using the base actions
isModeHasOwnActions: true with modeProps.actionsUse the mode's action list in place of the base list

Use inherited actions when the same command should work in every appearance. Use mode-specific actions only when the active state changes what the control should do.

For example, an Off state might offer Turn on, while the On mode offers Turn off. In that case:

  1. Put the turn-on action in the element's base action list.
  2. Enable the On mode's own actions.
  3. Configure its turn-off action in modeProps.actions.
  4. Test both states, including state changes received externally.

The mode's own list replaces the base list; it is not appended to it. Include every action that must run in that state. To suppress interaction through an empty action list, explicitly configure and test that behavior rather than assuming a dimmed appearance disables the control.

See Actions and navigation for events, signal types, and value handling.

Styling practices​

  • Change text or an icon as well as color when users need to distinguish states clearly.
  • Keep the base appearance complete so an unknown state still has a readable fallback.
  • Override only the properties needed for the mode; keep shared styling in the base element or theme.
  • Use meaningful, distinct mode names and document numeric mappings from the control program.
  • Keep the element's geometry stable for status-only changes unless movement or resizing is intentional.

For example, a source button can preserve its dimensions, font, and icon position while changing its label, icon color, and background when selected.

Troubleshooting​

SymptomWhat to check
The mode exists but never appearsCheck activeModeIndex; creating a mode alone does not select it
A boolean selects the wrong appearanceFalse maps to Default and true maps to the first added mode; check mode order
The second mode never appears with a booleanUse a numeric or named selector when more than two appearances are needed
A named state falls back to DefaultCheck the supplied name and the defined modes
Every repeated card shows the same stateA global variable is shared; use per-instance page parameters when each card needs independent state
A property unexpectedly revertsCheck whether it is set in Default or only overridden in one mode
Pressing an Unavailable control still sends a commandVisual styling does not disable actions; inspect inherited or mode-specific behavior
Base actions stop runningCheck whether the active mode enables its own action list
State updates locally but not from equipmentVerify the external binding, connector, and value type separately from the appearance
The selected appearance changes after reordering modesUpdate numeric selectors to match the new one-based order

Verify the complete setup​

  1. Save and run Run Project Health Check.
  2. Test Default and every added mode in Live Preview.
  3. Test transitions in both directions, not just the initial appearance.
  4. Check unknown named values return to a usable Default state.
  5. Verify labels, icons, contrast, and touch geometry in every appearance.
  6. Test inherited and mode-specific actions independently.
  7. With equipment connected, test state changes made outside this interface.

Continue with Variables and parameters, Actions, Themes, and Subpages.