Join the Webstudio community

k
kvi
Offline, last seen 2 months ago
Joined January 7, 2025
Is there a way to use Data Variables in CSS, if not what is the best workaround?
Example:
  1. Create slider input and bind it to Data Variable "sliderValue"
  2. Change the css attribute (text size or opacity) based on "sliderValue" (i.e. bind "sliderValue" to css variable)
2 comments
J
k
Is there some way to write to "Data Variables" via the code in HTML Embed?
Plain Text
# in HTML Embed
<script type="module">

  # possible
  const arr = ${someArray};

  # not possible, is there a workaround?
  ${someArray} = JSON.stringify([1, 2, 3]);

</script>
5 comments
k
J
O
How how to bind js variable to the Collection? If it is not possible, do I need to manually recreate functionality of Collection element in the HTML Embed? What is the best way to achieve functionality of Collection with js variables?
4 comments
O
k