Macro css_rs_macro::css

source ·
css!() { /* proc-macro */ }
Expand description

Parses the syntax for writing inline css. Every call to css! will have its class name incremented by one.

So your first css! call is class “._css_rs_0”, then “._css_rs_1”, etc.

To write your css to a file use:

OUTPUT_CSS=/path/to/my/output.css cargo run my-app

Examples

#![feature(use_extern_macros)]
#![feature(proc_macro_non_items)]

extern crate css_rs_macro;
use css_rs_macro::css;

fn main () {
    let class1 = css! {
      "
      :host {
        background-color: red;
      }

      :host > div {
        display: flex;
        align-items: center;
      }
      "
    };

    let class2 = css! {r#"
        :host { display: flex; }
    "#};

    assert_eq!(class1, "_css_rs_0".to_string());
    assert_eq!(class2, "_css_rs_1".to_string());
}