css-in-rs
A library for embedding dynamic CSS in Rust (wasm); inspired by cssinjs/JSS
This crate is designed to be framework-independent. It currently provides integrations for Dioxus, which is disabled by default.
Use case
This crate allows to develop reusable components for the web which bundle their own styles. Dead-Code-Analysis works as usually with Rust: If you do not need a certain component, its styles won't be embedded in the final binary.
The classnames are generated at runtime to avoid collisions (i.e. css-123
).
Basic idea
The make_styles!
procmacro allows you to write CSS-like style sheets directly in Rust. You can
use normal class names without worrying about collisions. Even if another component uses the same
name, it does not matter. The procmacro automatically determines the classnames from the style
and generates a helper class containing the real class names.
Example (Dioxus):
use ;
use *;
make_styles!