Skip to content
Discussion options

You must be logged in to vote

For classes that never change, you don't need the tuple syntax at all — just use the plain class attribute with a normal string:

view! {
    <h1 class="font-red text-red color-red bg-purple-400">"Welcome to Leptos!"</h1>
}

That's the idiomatic way to set static (including static Tailwind) classes. Both of your examples work, but they're using machinery meant for a different job:

  • class:name=condition — toggles one class reactively, e.g. class:font-red=move || is_active().
  • class=("name", condition) — same idea, for a single class name the view! macro can't parse as an identifier (hyphens, slashes, etc.).
  • class=(["a", "b", "c"], condition) — toggles a list of classes together based on one c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by arami21-space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants