I have 2 repeaters, and 2 layout switch buttons respectively. When one layout button is pressed, they should switch styles.
Video:
As seen in the video, Layout 1 (left button) style is not changed, that is because it is a gradient and not a color. I was not able to find reference to gradients in Velo code. How can I swap the button styles onClick? The other option is to have 4 buttons that hide/display with code, but I would prefer not to do that, and change design with code.
Despite the video, I don’t understand what you’re trying to change.
Can you elaborate? (maybe post a screenshot and put an arrow pointing to the element you’d like to change) + explain what type of element you wish to change, is it a button? a vector element? a box? an image?
I’m basically trying to swap the button designs. The issue is that the selected button has a gradient, so I am not sure how to change gradient with Velo.
Unfortunately, the Velo API does not support assigning gradient background to buttons.
But there’re still some workaround you can do in order to achieve the same effect.
Option one - custom element:
Instead of using Wix Button, create a button of your own using custom element (only if the website is connected to your own domain)
This way is clean and simple but requires some basic knowledge in html and css (and custom components),
Option 2 - svg:
Instead of buttons, use boxes .
In each box put a vector element (i.e. decorative rectangle). Over the vector element put the mode icon (I mean the layout white squares).
Create an svg file/code with the gradient and assign it to the vector element src.
Now assign the on click event listeners to the parent box and change the vector src in the event handler block.
Hi,
First the code from the custom element must be in:
public/custom-elements/FILE_NAME.js’
Second, you can just paste html code their. You need to build it in a custom element class. See docs here: