Style
Learn how the style attributes work.
background
The background attribute will let you specify a color as the background of the element.
You can learn about the syntax of this attribute here.
Example:
#![allow(unused)] fn main() { fn app(cx: Scope) -> Element { render!( rect { background: "red" } ) } }
Compatible elements: rect
shadow
The shadow attribute let's you draw a shadow outside of the element.
Syntax: <x> <y> <intensity> <size> <color>
Example:
#![allow(unused)] fn main() { fn app(cx: Scope) -> Element { render!( rect { shadow: "0 0 25 2 rgb(0, 0, 0, 120)" } ) } }
Compatible elements: rect
corner_radius & corner_smoothing
The corner_radius attribute let's you smooth the corners of the element, with corner_smoothing you can archieve a "squircle" effect.
Example:
#![allow(unused)] fn main() { fn app(cx: Scope) -> Element { render!( rect { corner_radius: "10", corner_smoothing: "75%" } ) } }
Compatible elements: rect
border
You can add a border to an element using the border and border_align attributes.
bordersyntax:[width] <solid | none> [color].border_alignsyntax:<inner | outer | center>.
Example:
#![allow(unused)] fn main() { fn app(cx: Scope) -> Element { render!( rect { border: "2 solid black", border_align: "inner" } ) } }
Compatible elements: rect
overflow
Specify how overflow should be handled.
Accepted values: clip | none.
Example:
#![allow(unused)] fn main() { fn app(cx: Scope) -> Element { render!( rect { overflow: "clip" width: "100", height: "100%", rect { width: "500", height: "100%", background: "red", } } ) } }
Compatible elements: rect
Color syntax
The attributes that have colors as values can use the following syntax:
Static colors
rectbluegreenyellowblack(default forcolorattribute)graywhite(default forbackgroundattribute)orangetransparent
rgb() / hsl()
- With RGB:
rgb(150, 60, 20) - With RGB and alpha:
rgb(150, 60, 20, 70) - With HSL:
hsl(28deg, 80%, 50%) - With HSL and alpha:
hsl(28deg, 80%, 50%, 25%)
Inheritance
These are some attribute that are inherited from the element parents:
colorfont_familyfont_sizefont_stylefont_weightfont_widthline_heightalignmax_linesletter_spacingword_spacingdecorationdecoration_styledecoration_colortext_shadow