Skip to content

Changing the width of an element based on the value of a react variable #4431

Discussion options

You must be logged in to vote

@cordobadigitalmedia This is probably not working because of your purge settings. So because you don't explicitly have w-2 w-4 ... in your file, these classes are not generated (if mode = JIT) or being removed (if mode != JIT).
See here for more details.

However, here it is a lot easier if you use inline style:

<div className="bg-lime-500 ..." style={{width: `${currentTime}px`}}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
1 reply
@cordobadigitalmedia
Comment options

Answer selected by cordobadigitalmedia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants