[!NOTE] This crate is part of mevy (tl;dr: more neat macros) so take a look! 🦆
⭐ The Star of the Crate: CSS-like Notation
Using ui!((..)) (inner round braces) will return a tuple of mentioned components only. See this example.
c.spawn;
//^ optional ? (or any token): hovering shows the returned tuple (if LSP used)
/// function as custom fields or p refabs
Neat Notation
Inside the macro there you can write those things:
0px=Val::Px(0.)0%=Val::Percent(0.)0vh=Val::Vh(0.)0vw=Val::Vw(0.)0vmin=Val::VMin(0.)0vmax=Val::VMax(0.)#ff0000=Color::Srgba(Srgba::hex("#ff0000").unwrap())red|RED=bevy::color::palettes::css::RED
Custom Fields
Currently, There are 2 ways to add those:
- a
fnthat returns something thatimpl Bundle - the
newmethod of a struct thatimpl Bundle
c.spawn;
Edge Selection (CSS-like)
border: 5px; // 5px to all edges
border: 5px 2px; // 5px vertical, 2px horizontal
border: 5px 2px 8px; // 5px top, 2px horizontal, 8px bottom
border: 5px 2px 4px 1px // (clockwise) top right bottom left
Corner Selection (CSS-like)
border-radius: 5px; // 5px to all corners
border-radius: 5px 0px; // 5px top-left/right, 0px bottom-left/right
border-radius: 5px 2px 8px; // 5px top-left, 2px top-right, 8px bottom
border-radius: 5px 2px 4px 1px // (clockwise) top-left top-right bottom-right bottom-left
Limitations
At the moment, you can only use variables in custom fields. It's planned to work for built-in fields soon™.
Built-In Fields
Here's a list of all available out of the box fields, Val order same as in bevy
- numbers can be written as int or float
- enum variants can also be written in snake case
ui!