I’m having trouble figuring out the best way to use variable returned by vue functions in CSS inline styles, in this case the “width” style.
I have 2 variables being returned to the template that I can use with the {{}} syntax, but not as a CSS style.
This works fine:
Total Staked {{ gems }}/{{ size }} ({{
Math.round((gems / size) * 100)
}}%)
This looks like this when rendered: Total Staked 200/350 (57%)
I would like to put that calculated percentage (57%) into css inline style like this:
<div class="bg-black h-2 rounded-md text-white" style="width: 57%"></div>
where the width: 57% is populated dynamically.
I am using Vue 3 with Tailwind CSS
Here is a Codepen: https://codepen.io/johnwinsor/pen/RwxvdZZ
Thank you!
<progress value="" max="">tag. This article may help you to style progress bar