Row
Lays objects out left to right. Adapts deterministically when space runs out.
A toolbar
A Row lays its objects out left to right with a gap. xAlign distributes them along the row, yAlign aligns them across it, and align sets both at once.
Row(
.config(
w: fill
color: panel
cornerRadius: 12
gap: 12
padding: all(14)
xAlign: between
yAlign: mid
)
Text(.config(size: 15, weight: semibold) .obj('Inbox'))
Row(
.config(gap: 8)
Container(
.config(color: sunken, cornerRadius: 999, padding: sym(x: 10, y: 4))
.obj(Text(.config(size: 12, color: muted) .obj('12 new')))
)
Container(
.config(color: accent, cornerRadius: 999, padding: sym(x: 10, y: 4))
.obj(Text(.config(size: 12, color: onAccent) .obj('Compose')))
)
)
)When space runs out
A row of fill objects stacks into a column when one of them would be squeezed below a comfortable width, and a row of fixed or hugging objects wraps. Nothing to write: switch the preview to m to see it.
Row(
.config(w: fill, gap: 12)
Container(.config(w: fill, h: 64, minW: 220, color: violet, cornerRadius: 12))
Container(.config(w: fill, h: 64, minW: 220, color: teal, cornerRadius: 12))
)Config keys
| Key | Type | Default | Meaning |
|---|---|---|---|
w (width) | len | fill | hug | Width: a length, fill (share the remaining space) or hug (fit content, default). | |
h (height) | len | fill | hug | Height: a length, fill or hug (default). | |
size (s) | size | Width and height together: size: 200 or size: (200, 120). | |
minW (minWidth) | len | Minimum width. | |
maxW (maxWidth) | len | Maximum width. | |
minH (minHeight) | len | Minimum height. | |
maxH (maxHeight) | len | Maximum height. | |
aspect (aspectRatio) | num | Aspect ratio (width / height), e.g. 16/9. | |
color (bg, background, colorBG) | paint | Background paint: a colour or gradient. | |
padding (pad) | insets | Space inside the object. | |
cornerRadius (radius, borderRadius, corner) | radius | Corner radius: one length or only(topLeft: 8, …). | |
borderWidth | len | Border width. | |
borderColor | color | Border colour. | |
borderAlign | in | mid | out | in | Where the border sits relative to the edge: in, mid or out. |
borderStyle | solid | dashed | dotted | solid | Border line style. |
borderSides | all | top | bottom | left | right | x | y | all | Which sides draw the border (inside the box). |
shadow | shadow | Drop shadow(s): shadow(y: 4, blur: 12, color: black.alpha(20%)). | |
clip | bool | Clip children to the object's bounds (and corner radius). | |
z | int | Stacking order among siblings. | |
margin | insets | Space outside the object: all(8), sym(x: 8, y: 4), only(top: 8). | |
opacity | num | Opacity from 0 to 1. | |
hide (hidden) | bool | Removes the object from layout and the accessibility tree. | |
shrink | num | 1 | Shrink priority when space runs out. Lower shrinks first; 0 never shrinks. |
flex | num | 1 | Share of remaining space for fill sizes. |
cursor | auto | pointer | text | grab | grabbing | move | notAllowed | crosshair | none | Pointer cursor. | |
className (class) | txt | Extra CSS class names: styling hooks for your own stylesheet (hover rules, third-party CSS). | |
align (alignment) | align | Both axes at once, e.g. align: mid or align: bottomRight; xAlign and yAlign override one axis. | |
xAlign (mainAxisAlignment) | axis | start | Horizontal distribution along the row. |
yAlign (crossAxisAlignment) | axis | start | Vertical alignment of children. |
gap (spacing) | len | Space between children. | |
overflow | auto | wrap | stack | scroll | clip | shrink | warn | error | auto | What happens when content does not fit. auto adapts deterministically (see Layout & Adaptation). |
stackAt | len | Row only: the width below which the row stacks into a column (computed automatically when omitted). | |
reverse | bool | Reverse the visual order. |
Group .border(align, color, width, style, sides): Border settings grouped: .border(align: in, color: #0d0d0d, width: 2).
Slots
.objs: several objects, the default slot
Events
.on(...) accepts tap, press, hover, hoverEnd, focus, blur, key, drag, swipe, mount, unmount, visible.