Macro dominator::pseudo

source ·
macro_rules! pseudo {
    ($this:ident, $rules:expr) => { ... };
    ($this:ident, $rules:expr, { $($methods:tt)* }) => { ... };
}
Expand description

Adds a pseudo rule to a class! stylesheet.

A pseudo rule is either a pseudo class or a pseudo element.

The first argument is a string, or an array of strings.

The second argument is a block of method calls. Inside of the block you can use ClassBuilder methods:

class! {
    .pseudo!(":hover", {
        .style("color", "green")
        .style("background-color", "blue")
        .style_signal("width", ...)
    })
}

The block uses the apply_methods! macro, see the docs for apply_methods! for more details.

If the first argument is an array of strings, it will try each pseudo rule in order until it finds one that works.

This is useful for using browser prefixes:

class! {
    .pseudo!([":any-link", ":-webkit-any-link"], {
        ...
    })
}