A multi-state box contains multiple states with different content, and displays a single state at a time. Each state corresponds to a specific situation or status. You need to add code to your site to define when each state is displayed. This article demonstrates how to set up your multi-state box using code.
To set up your multi-state box, follow this general procedure:
changeState() function with the state you want to move to.This example shows how to set up your multi-state box so that site visitors can switch between states by clicking a button and then focus on the button in the currently displayed state to enhance keyboard and screen reader functionality for visitors with disabilities.
We added a multi-state box to our page called myStateBox, with 2 states called state1 and state2. Then we added a button to each state for switching between the states.
Note You can view and change your multi-state box and state IDs in the Properties & Events panel.
myStateBox: ID of my multi-state box.state1: ID of the current state, State 1.button1: ID of button to click to move to State 2.myStateBox: ID of my multi-state box.state2: ID of the current state, State 2.button2: ID of button to click to move to State 1.Add the following code to your page. This code sets up click handlers for both buttons that switch between states and focus on the appropriate button in each state:
You can adapt this scenario to enable site visitors to:
Note: The images in this example show the multi-state box in the Wix Editor. The multi-state box in Wix Studio functions similarly to Wix Editor, with the only difference being its appearance, as demonstrated in the example above.
This example shows how to set up your multi-state box with code so that a different state is displayed depending on a particular status. The example uses Wix Store products, but you can adapt the example for other scenarios.
We added a multi-state box to our Wix Stores product page that displays a different badge depending on the product's status.
We added 3 states to our multi-state box:

badgeStatebox: ID of my multi-state box.outOfStock: ID of the current state. For products that are out of stock.
badgeStatebox: ID of my multi-state box.onSale: ID of the current state. For products that are on sale.
badgeStatebox: ID of my multi-state box.featured: ID of the current state. For products that aren't on sale or out of stock.Add the following code to your product page. This code listens for product changes and displays the appropriate badge state based on the product's availability and pricing:
Tip If you want some products not to display a badge at all, you could hide() the multi-state box when particular conditions are met.
You can adapt this scenario to: