Skip to content

struct

Stylesheet

pub struct Stylesheet {
    /* private fields */
}

Rules for every class seen so far, emitted in precedence order.

Methods

new

pub fn new(theme: Theme) -> Stylesheet

An empty stylesheet for theme.

without_preflight

pub fn without_preflight(self) -> Stylesheet

Omit PREFLIGHT from the output.

theme

pub fn theme(&self) -> &Theme

The theme its rules use.

add_class

pub fn add_class(&mut self, class: &str) -> bool

Add one class; returns whether a new rule was created.

add_classes

pub fn add_classes(&mut self, classes: &str) -> bool

Add every class in a class attribute; returns whether anything new was generated.

contains

pub fn contains(&self, class: &str) -> bool

Whether class has been added and produces CSS.

len

pub fn len(&self) -> usize

How many rules it holds.

is_empty

pub fn is_empty(&self) -> bool

Whether it holds no rules.

css

pub fn css(&self) -> String

The complete stylesheet.

font_faces

pub fn font_faces(&self) -> BTreeSet<String>

Every @font-face rule the sheet needs (from its classes and the theme's base styles).

css_without_font_faces

pub fn css_without_font_faces(&self) -> String

[Stylesheet::css] without its [Stylesheet::font_faces]: a browser downloads a font again whenever its @font-face rule is re-parsed, so a page that rewrites its stylesheet keeps those apart.

Trait implementations