How to use conditional styles? #54
-
Hi, |
Beta Was this translation helpful? Give feedback.
Answered by
kavinvalli
Oct 18, 2023
Replies: 1 comment 1 reply
-
It just works like any other variable inside a template literal. const className = `${tw.some_common_class} ${active ? tw.class_you_want : tw.some_other_class}` That being said, I recommend using the clsx and tailwind-merge packages to work with conditional classes ps: I wrote this answer on my phone so please ignore any typos/syntax errors |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
60pfennig
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It just works like any other variable inside a template literal.
That being said, I recommend using the clsx and tailwind-merge packages to work with conditional classes
ps: I wrote this answer on my phone so please ignore any typos/syntax errors