Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for Leptos classes #14

Open
BugraEryilmaz opened this issue Feb 16, 2025 · 1 comment
Open

Workaround for Leptos classes #14

BugraEryilmaz opened this issue Feb 16, 2025 · 1 comment

Comments

@BugraEryilmaz
Copy link

BugraEryilmaz commented Feb 16, 2025

Hi,

I am just starting to use leptos and stylance for the first time. There is an annoying interaction with the Leptos framework. You can have class:name tags, which is very nice to use, and you can only have one class=<function> tag. The idea is to have dynamic stuff with the first approach and static stuff with the second. The problem is the following code does not work because it assigns the class week::calendar instead of evaluating the value. If we change : to = to have functions, it gives an error for having multiple class tags.

stylance::import_style!(#[allow(dead_code)] week, "week.css");
#[leptos::component]
pub fn Week() -> impl IntoView {
    return view! {
        <div class:week::calendar
             class:week::button />
    };
}

Is there a workaround for this?

@basro
Copy link
Owner

basro commented Feb 16, 2025

Stylance includes the utility classes! macro that can be used to combine multiple classes into a single string which you'd pass to the element's class attribute. I think this is what you are looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants