Changing HTML element based on state

Is there a way to change the HTML in the HTML element based on its state? My use case is switching an outlined icon with a filled icon if the state is hovered.

Generally, it seems like the HTML field is not responsive to the state at all (i.e. it’s the same across all states). Why is that?

Jack

CleanShot 2023-09-22 at 14.09.37

You can add conditions to bind. You could do something like

if([yourvalue]=true) then you set the element to div
Else set it to span

@Broberto I was hoping to do this with states instead of having a variable that has to be configured via hover in/hover out workflows. But that seems like the only way.

If the state variable was exposed (I’ll try to dig it out) it would be as simple as listening to that variable. Maybe you can do a feature request here https://feedback.weweb.io

Hey,
at the moment this field is neither responsive neither statefull, as we did not think they were usecase when it was usefull.
Do not hesitate to post on the link Broberto gave to expose your usecase so we could think about adding the feature :slight_smile:

So yeah, for now you can handle this by a variable tho :slight_smile: as I mentioned before

1 Like

Just adding, you might want to do it with a ternary operator like this

([your_value] === true) ? "div" : "span"