CSS Styling
Azul uses CSS for styling UI elements. This guide covers supported properties and patterns.
Inline Styles
Apply styles directly to elements:
div
.with_inline_style
Flexbox Layout
Azul supports Flexbox for layout:
// Horizontal layout
div
.with_inline_style
.with_children
// Vertical layout
div
.with_inline_style
Flexbox Properties
| Property | Values |
|---|---|
display |
flex, block, inline, none |
flex-direction |
row, column, row-reverse, column-reverse |
flex-wrap |
nowrap, wrap, wrap-reverse |
justify-content |
flex-start, flex-end, center, space-between, space-around |
align-items |
flex-start, flex-end, center, stretch, baseline |
align-content |
flex-start, flex-end, center, stretch, space-between, space-around |
gap |
<length> |
Box Model
div
.with_inline_style
Typography
div
.with_inline_style
Colors
Supported formats:
/* Hex */
/* Short hex */
); /* RGB */
); /* RGBA */
/* Named colors */
Backgrounds
div
.with_inline_style
Borders
div
.with_inline_style
Shadows
div
.with_inline_style
Overflow and Scrolling
div
.with_inline_style
Positioning
// Relative positioning
div
.with_inline_style
// Absolute positioning
div
.with_inline_style
Hover and Active States
Add dynamic styles using add_hover_css_property and add_active_css_property:
use ;
const HOVER_BG: = ;
let mut button = div
.with_inline_style
.with_child;
button.root.add_hover_css_property;
Cursor Styles
div
.with_inline_style // Hand cursor
.with_inline_style // Text cursor
.with_inline_style // Move cursor
Units
| Unit | Description |
|---|---|
px |
Pixels |
% |
Percentage of parent |
em |
Relative to font size |
rem |
Relative to root font size |
vh |
Viewport height |
vw |
Viewport width |
calc() Function
div
.with_inline_style
Supported Properties Reference
Layout
display,position,top,right,bottom,leftwidth,height,min-width,max-width,min-height,max-heightmargin,padding(and all variants)flex,flex-direction,flex-wrap,flex-grow,flex-shrink,flex-basisjustify-content,align-items,align-self,align-contentgrid-template-columns,grid-template-rows,grid-column,grid-row,gap
Visual
background,background-color,background-imageborder,border-radius,box-shadowcolor,opacityoverflow,overflow-x,overflow-y
Typography
font-family,font-size,font-weight,font-styleline-height,text-align,text-decoration
Interaction
cursor,user-select