futursolo / stylist-rs

A CSS-in-Rust styling solution for WebAssembly Applications
https://crates.io/crates/stylist
MIT License
366 stars 22 forks source link

Do we support defining pseduo class with this library? #85

Open Mng12345 opened 1 year ago

Mng12345 commented 1 year ago

As the title, there is no documentation i can find about how to use pseduo class in stylist-rs.

WorldSEnder commented 1 year ago

Yes, this is supported. E.g. in a styled component

let hover_class = css!(
  :hover {
      color: blue;
  }
);

You can think of all selectors in a css! block to implicitly mention "the currently generated class", so the above results in css like

.stylist-style-0:hover {
    color: blue;
}

being mounted the <head> and using the hover_class will attach the class stylist-style-0 to your component.

Mng12345 commented 1 year ago

@WorldSEnder Thanks, but it's still not very clear to me, could you put an example into the directory examples of this repository?

WorldSEnder commented 1 year ago

Can you give a short description what you are trying to achieve and which pseudo class you would like to see, so I can provide a tailored example?