Stylist is a CSS-in-Rust styling solution for WebAssembly Applications.
This is a fork of css-in-rust.
Add the following to your Cargo.toml
:
toml
stylist = "0.10"
For detailed usage, please see documentation.
To style your component, you can use styled_component
attribute with css!
macro.
```rust use yew::prelude::*; use stylist::yew::styled_component;
fn MyStyledComponent() -> Html { html! {
To create a stylesheet, you can use style!
:
```rust use stylist::style;
let style = style!( // A CSS string literal r#" background-color: red;
.nested {
background-color: blue;
width: 100px
}
"# ).expect("Failed to mount style");
// stylist-uSu9NZZu println!("{}", style.getclassname()); ```
If you want to parse a string into a style at runtime, you can use Style::new
:
```rust use stylist::Style;
let style_str = r#" background-color: red;
.nested {
background-color: blue;
width: 100px
}
"#;
let style = Style::new(style_str).expect("Failed to create style");
// stylist-uSu9NZZu println!("{}", style.getclassname()); ```
There's theming example using Yew Context API.