Skip to content

Is there an ability to include multiple classes dynamically with one statement? #3053

Closed Answered by gbj
zoryamba asked this question in Q&A
Discussion options

You must be logged in to vote

Here's an example with three different ways to do what you're asking. Take your pick!

let index = RwSignal::new(0);
let i = 0;

let condition = move || index.get() == i;

view! {
    <div class=(["active", "dark"], move || index.get() == i)></div>
    <div class:active=condition class:dark=condition></div>
    <div class=move || (index.get() == i).then_some("active dark")></div>
}

Replies: 3 comments 1 reply

Comment options

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

You must be logged in to vote
0 replies
Comment options

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants