项目
在 GitHub 查看
futursolo/stylist-rs
关于
A CSS-in-Rust styling solution for WebAssembly Applications
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Stylist
Stylist is a CSS-in-Rust styling solution for WebAssembly Applications.
This is a fork of css-in-rust.
Install
Add the following to your Cargo.toml:
stylist = "0.14"
Usage
For detailed usage, please see documentation.
Yew Integration
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>}
}
Standalone
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());
Runtime Style
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());
Theming
There's theming example using Yew Context API.
探索相关项目
加载中…