All Projects → futursolo → stylist-rs

futursolo / stylist-rs

Licence: MIT license
A CSS-in-Rust styling solution for WebAssembly Applications

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to stylist-rs

zzhack
🦀️ WASM webapp template written in Rust
Stars: ✭ 170 (+37.1%)
Mutual labels:  yew
FullstackRustDemo
Novelty website + bucket questions implementation.
Stars: ✭ 40 (-67.74%)
Mutual labels:  yew
surfer
The Blog built on pure Rust stack. Backend for graphql services, and frontend for web application.
Stars: ✭ 35 (-71.77%)
Mutual labels:  yew
paudle
Wordle in Rust
Stars: ✭ 40 (-67.74%)
Mutual labels:  yew
reacty yew
Generate Yew components from React components via Typescript type definitions
Stars: ✭ 46 (-62.9%)
Mutual labels:  yew
portfolio
My Portfolio
Stars: ✭ 17 (-86.29%)
Mutual labels:  yew
Yew-WebRTC-Chat
A simple WebRTC chat made with Yew
Stars: ✭ 112 (-9.68%)
Mutual labels:  yew
yew form
Components to simplify handling forms with Yew
Stars: ✭ 83 (-33.06%)
Mutual labels:  yew
facade
Facade Framework - autogenerated embedded live dashboards for Rust apps
Stars: ✭ 95 (-23.39%)
Mutual labels:  yew
yew-router
Router extension to yew
Stars: ✭ 27 (-78.23%)
Mutual labels:  yew
wasi-worker
WASM / WASI interface for browser service workers
Stars: ✭ 31 (-75%)
Mutual labels:  yew
patternfly-yew
PatternFly components for Yew
Stars: ✭ 51 (-58.87%)
Mutual labels:  yew
ybc
A Yew component library based on the Bulma CSS framework.
Stars: ✭ 131 (+5.65%)
Mutual labels:  yew
rust-electron-demo
rust electron demo using yew
Stars: ✭ 15 (-87.9%)
Mutual labels:  yew
rusty-connect4
A full-stack application written completely in Rust.
Stars: ✭ 30 (-75.81%)
Mutual labels:  yew
fullstack-rust
Reference implementation of a full-stack Rust application
Stars: ✭ 39 (-68.55%)
Mutual labels:  yew
rocket-yew-starter-pack
Example boilerplate for websites in pure Rust
Stars: ✭ 77 (-37.9%)
Mutual labels:  yew
material-yew
Yew wrapper for Material Web Components
Stars: ✭ 116 (-6.45%)
Mutual labels:  yew
bounce
The uncomplicated Yew State management library
Stars: ✭ 43 (-65.32%)
Mutual labels:  yew
lifeee-rs
An implementation of the Game of Life
Stars: ✭ 53 (-57.26%)
Mutual labels:  yew

Stylist

Run Tests & Publishing crates.io download docs.rs

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.10"

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(MyStyledComponent)]
fn my_styled_component() -> 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].