I’m having trouble with
I’m trying to create a vertical tab or accordion to get additional text on the page without taking up so much space. I’m trying to figure out if there could be a workaround with a button and text box. There will be 3 buttons with 1 paragraph text box. Can I make some of the text boxes hidden until the button is clicked and switch the text over?
Working in
I’m working in Wix Editor. Will this require Dev mode to make some of the text hidden?
There’s a few different options I think you could use. For a more similar view to what you have but without the need for code, you can Wix FAQ since that allows for collapsing questions and answers. It’s not exactly the same layout but despite it being Q&A, you could customize the text being used.
You can also use tabs but then the button would be on the paragraph text.
Another option is using a multi-state box to manage the bullet points and using code to change the state for the points. Here’s a screenshot of the layout and below will be the code.
And the best part about building a website is there’s usually multiple approaches. I did something similar with a multistate box and a menu component before:
Using Noah’s example, it would be possible to change what’s written on the menu items. In this case, Noah is doing it with the code.
label: "Sets",
id: "sets"
That portion of the code is how he’s doing it with label being what users see listed on the site and id being the name the code uses to work with.
His example is also bit cleaner than mines since he’s using arrays (a collection of values) to manage his. Here’s how the code above I sprung together looks using that principal. You can see how much cleaner it is and shorter it is, plus it’s easier if you wanted to have more buttons.
I figured I’d share the above first since it’s easier to understand in case you don’t code that when you press #button1 it changes the state of the multibox to State1.
With the code above, you’re telling the code the buttons could be #button1, #button2 and #button3 and the states are 1, 2, and 3 respectively. Using the variables (the name following const), the code is able to fill in the “gap” and draw from those listed values.
I hope that’s a bit clear and helps demystify both our code.
Thank you both @noahlovell and Rob . My coding ability is basic, so the multi-state box is probably the easiest way to achieve this. I will probably have a play around with the buttons to try and see if I can create a clean version to add to the website.
Both of your suggestions and advice has been helpful. I’m a new user so can only tag one person in to a post at a time.