#style-sheet #css #represents #macro

nightly macro rustyle

A new way to represent the CSS stylesheet in Rust

1 unstable release

0.1.0 Mar 23, 2019

#17 in #represents

MIT license

19KB
539 lines

rustyle

A new way to represent the CSS stylesheet in Rust

Basic Information

Read like [rough style]. It seems like styled-components, emotion, glamor, and other CSS-in-JS libraries. It's basically inspired by their concepts. But more friendly with rust.

Syntax

Write CSS-in-Rust like this! (We call it rusty css syntax)

let CLASS = css! {
  background-color: gray;

  &:hover {
    background-color: lighten!(15%, gray);
  }

  &:not(:hover) > p {
    display: none;
  }
}

How's it works

It's written in proc macro. The css codes checked and wrote at compile time. macro calls replaced to randomly generated class names.


lib.rs:

This crate provides the rustyle! macro that allows using CSS-in-Rust for Rust frontend application.

Dependencies

~2.5MB
~48K SLoC