Selector
hobo selectors mirror CSS selectors with minor changes, most notably:
- descendant selectors like
div abecomediv >> abecause Rust doesn't have semantic whitespaces.- selectors like
div.activework mostly the same (except have to be written likediv.("active")ordiv .("active"))
- selectors like
- ids have to be written like
#("foo-1234") - pseudo-classes use
_instead of-and must always use single colon syntax, e.g.:activeor:last_child- there's an escape hatch in
:raw("-webkit-prop".to_string())for browser-specific or other weird things
- there's an escape hatch in
- pseudo-elements use
_instead of-and must always use double colon syntax, e.g.::afteror::first_line
There are also several additions:
.&will be replaced at runtime with the name of a class, which will be generated from the rules in the style it belongs to- in other words, it's similar to
&in SASS orstyled-components
- in other words, it's similar to
.[T]whereTis some marker type will be replaced with the generated classname for the typeTso you could select based on custom marker type.
use hobo::create as e;
struct ButtonMarker;
e::div()
.class(css::style!(
.& >> .[ButtonMarker] {
css::cursor::pointer,
}
))
.child(e::div()
.mark::<ButtonMarker>()
.text("button 1")
)
.child(e::div()
.mark::<ButtonMarker>()
.text("button 2")
)