Skip to content

Dynamic bg color is not working has I accepted . #11189

Closed Answered by IntuzParthD
IntuzParthD asked this question in Help
Discussion options

You must be logged in to vote

After reading the tailwind documentation ,
I founded one of the way by which we can use the classes dynamically.
For example let colour be green, red, yellow, purple and we want to use it like className =bg-${color}-500.
while writing this directly we will not see any dynamic colour change in ui . So, to successfully use it we should write somewhere in the code for initialising the colours for example

...
//some where in the code
let colours = "bg-green-500 bg-red-500 bg-yellow-500 bg-purple-500"

//And now we can use this colour dynamically in the code, We can see the reflect in ui too.
//Here color can be green, red,yellow,purple
... className=bg-${color}-500 ...

Replies: 6 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@IntuzParthD
Comment options

@hamirmahal
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by IntuzParthD
Comment options

You must be logged in to vote
3 replies
@IntuzParthD
Comment options

@hydra1197
Comment options

@hydra1197
Comment options

Comment options

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

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
5 participants