Scoped styles macro! #583
eboody
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
|
Thanks for writing this up! I'm going to cross-post it to our Discord, which has a lot of active discussion as well. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey guys!
I made a macro that wraps around Leptos's view! macro to make it really easy to add scoped styles to your components!
Let me know what you think! The crate is available at crates.io
Styled: Easy Styling for Leptos Components
If you're looking for an easy way to apply scoped styles to your
Leptoscomponents,Styledis the Leptos macro you need. WithStyled, you can apply high-level selectors likebuttonordivto specific components, keeping your markup clean and organized.Installation
Use
cargo addin your project rootUsage
First create a basic
Leptoscomponent. This will serve as the foundation for this little guide.Next, import the
stylemacro, powered by an awesome crate calledStylist, to create your styles.Just add this to the top of your file.
You can then use the
stylemacro to create aResultcontaining your styles. Let's modify our component:Now, let's apply those styles with our
styled::view!macro!Now we can define another component that also uses the
divCSS selector but it's styles will only apply to the elements inside of it's enclosingstyled::view!macro.Beta Was this translation helpful? Give feedback.
All reactions