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

IntoStyle for (&str, Option<T>)s #3568

Closed
luxalpa opened this issue Feb 9, 2025 · 2 comments
Closed

IntoStyle for (&str, Option<T>)s #3568

luxalpa opened this issue Feb 9, 2025 · 2 comments

Comments

@luxalpa
Copy link
Contributor

luxalpa commented Feb 9, 2025

Is your feature request related to a problem? Please describe.
Conditionally setting css styles on an HTML element.

Describe the solution you'd like
In Leptos 0.6 it was possible to provide an Option<T> or an fn -> Option<T> to style:cssprop= attributes (i.e. .style(("prop", Some("value"))). I was somewhat depending on that feature, but it seems it was forgotten during the upgrade to 0.7.

Describe alternatives you've considered
The workaround right now is to use style overrides (like .unwrap_or("auto") or use just a single style attribute for all styles and render the HTML. However both of these approaches have downsides as they are not able to precisely add and remove the singular style from the element.

Additional context
I've tried doing he PR myself but actually the trait relationships with asyncOutput etc are really difficult and I'm not deep enough in the new leptos code base to understand it although I did spend a couple of hours trying to get something to work.

@luxalpa
Copy link
Contributor Author

luxalpa commented Feb 9, 2025

I didn't know these are different but I actually need IntoStyle for the reactive function that returns an Option<T> for my use-case.

@gbj
Copy link
Collaborator

gbj commented Feb 16, 2025

Done for 0.8 in #3618

@gbj gbj closed this as completed Feb 16, 2025
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