Skip to main content
Version: 0.20

CSS with classes!

Yew does not natively provide a css in rust solution, but helps with styling by providing programmatic ways to interact with the html class attribute.

Classes​

The classes! macro and associated Classes struct simplify the use of HTML classes:

use yew::{classes, html};

html! {
<div class={classes!("container")}></div>
};

We will expand upon this concept in more CSS.

Inline Styles​

Currently Yew does not provide any special help with inline styles specified via the styles attribute, but you can use it like any other html attribute:

use yew::{classes, html};

html! {
<div style="color: red;"></div>
};

We will expand upon this concept in more CSS.