Does RSX offer a way to _add_ a CSS classes conditionally? #3092
Answered
by
ealmloff
bluenote10
asked this question in
Q&A
-
I know that RSX allows something like this: rsx! {
div {
class: if some_signal.get() { "some-class" },
"Hello, World!"
}
} However, what about the case when there are some common classes that should be extended (probably fairly common for tailwind users). This doesn't seem to compile, and so far I couldn't figure out a good solution: rsx! {
div {
class: "some common classes " + if some_signal.get() { "activated-class" }
"Hello, World!"
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ealmloff
Oct 24, 2024
Replies: 1 comment
-
Yes, you can add a second rsx! {
div {
class: "some common classes ",
class: if some_signal.get() { "activated-class" }
"Hello, World!"
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bluenote10
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, you can add a second
class
attribute that is optional. If they are both true, they will get merged automatically: