0.15.1 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform
Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.
MIT - MIT LicenseStylist 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:
stylist = "0.14"For detailed usage, please see documentation.
To style your component, you can use styled_component attribute with css!
macro.
use yew::prelude::*;
use stylist::yew::styled_component;
#[styled_component]
fn MyStyledComponent() -> Html {
html! {<div class={css!("color: red;")}>{"Hello World!"}</div>}
}To create a stylesheet, you can use style!:
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.get_class_name());If you want to parse a string into a style at runtime, you can use Style::new:
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.get_class_name());There's theming example using Yew Context API.