Skip to content

l5cs/scoped-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

framework agnostic scoped css for rust front-end frameworks.

basically a wrapper around [lightningcss] css modules implementation.

installation

cargo add --git https://github.com/l5cs/scoped-css.git scoped-css
cargo add --build --git ttps://github.com/l5cs/scoped-css.git scoped-css-build

how to use

//! build.rs

use scoped_css_build::compile_css;

fn main() {
    compile_css("src/**/*.css", "assets/main.generated.css");
}

dioxus example

use dioxus::prelude::*;
use scoped_css::{ScopedStyles, scoped_css};

const CSS_ASSET: Asset = asset!("/assets/main.generated.css");
const CSS: ScopedStyles = scoped_css!("main.css");

#[component]
pub fn Hero() -> Element {
    rsx! {
        div { class: CSS["scoped"],
            p { class: CSS["p"], "hello css" }
        }
    }
}

#[component]
fn App() -> Element {
    rsx! {
        document::Link { rel: "stylesheet", href: CSS_ASSET }
        Hero {}
    }
}

todo

  • sass
  • useful compilation errors
  • publish to crates.io?
  • examples for other frameworks

About

framework agnostic scoped css for rust front-end frameworks

Resources

Stars

Watchers

Forks

Contributors

Languages