How to create Tabs on Wix using Multi-State Box or Slideshow for Multi Interactions


Watch our tutorial above.  Listen to this blog post below.

About

A multi-state box is one of the newer elements that Wix has created.  It is meant to be used for creating interactive content, such as:


  • Tab Design
  • Multi-step registration
  • Multi-step form
  • Timed content
  • Read More design


Other times, people use the multi-state box without code so they can manually change the content as needed.  For example, you have a sale that will end until further notice so you have prepared 2 designs.  One design for when the sale is active, and the other design for when the sale is over.  Of course, the multi-state box works best when you add a little bit of code to bring the content to life via some sort of page interaction, like a button click or a hover, or some sort of automation.  If you are interested in timed content, be sure to check out our other tutorial that shows a few time content examples.  You can combine what you learn in both tutorials to create a time content using a multi-state box.In this tutorial we will review the two most popular uses for multi-state boxes:  using button clicks and hovers to change the multi-state box to a different 'slide'.  The code will also work for Slideshows but it is important to first learn the different between the two elements so you can decide which one will suit your project.


Link to live example:  https://codequeen.wixsite.com/tab-example


Follow Along #1

Add multi state box

You can add a multi-state box or slideshow to your site via the site editor panel under the 'interactive' category.  (Do not be alarmed if you find it in a different spot.  Wix likes to get created and move things around sometimes.  Simply use the search bar as seen in the top right corner of the image below.)

After you drag and drop your multi-state box onto your site, click on it to select 'Manage States' from it's editing options.  You can add a new state, duplicate an existing one and change the ID names of each state.  The state ID's will be used in coding.  

In this tutorial we will be creating a tab design that simulates the action of changing tabs via a button click.  This is the most basic and most popular use for the multi-state box.  It only requires a few lines of code and enhances your user's experience with interactive content that is also mobile friendly.


First we added  a couple of buttons and a few lines of text to our main state.  Since we want to create the illusion that the content is changing, we want our secondary tab to look similar.  The most efficient way of creating this illusions is by creating the first tab and then duplicating it when you are finished designing it.  This way, there is only minimal work to be done.


After we finished we labeled the states "first" and "second".  It is important to remember to avoid spaces and leading numbers when customizing any ID's for coding.


We updated the ID's of the two buttons that would be doing the actual navigation between the two states.  We labeled the buttons "goto2" and "goto1".  We also selected alternating colors to give the illusion that the button changed color after the button was clicked.  We did not code or link the extra buttons.  They were only added to as part of the visual design of the 'tab function'.

Be sure to watch our video tutorial above to see how the multi-state box acts in a responsive manner when one state has less or more content than the other.  Yes, it automatically resizes!


Follow Along #2

Add the page code

Now you add some code to the page via the code panel.  Be sure to replace our tutorial code with your actual element ID's found on your page for each element.  Since we are manually coding each event you do not need to use the event handlers from the properties panel.


$w.onReady(function () {

    $w("#goto2").onClick((event) => { //this is the button that takes you to the second state
        $w("#statebox8").changeState("second"); //this is the ID of your multi-state box
 });

    $w("#goto1").onClick((event) => {  //this is the button that takes you to the first state
        $w("#statebox8").changeState("first"); //this is the ID of your multi-state box
 });

});

Link to Velo Slideshow API:   https://www.wix.com/velo/reference/$w/slideshow 


Link to Velo Multi-State Box API:  https://www.wix.com/velo/reference/$w/multistatebox/changestate 


Link to Velo Button API:  https://www.wix.com/velo/reference/$w/button/onclick

Disclaimer
 

Our free and premium content is non-exclusive, meaning you are not the only one with access to the content. You can customize our content to fit your end product. Redistribution of our content is strictly prohibited. This means you cannot make our content available to others as-is, stand-alone products or stock products in ANY LANGUAGE, regardless if you offer our content for free or not.

 
Ï