Adapt
Shows the first candidate layout that fits the available space.
Also written ViewThatFits; layr format rewrites these to Adapt.
A navigation that changes form
Adapt shows the first of its candidates that fits the space it is given. Write them from the most preferred to the most compact: a full row of links on a wide screen, a shorter one where that does not fit, a single button when nothing else does.
Adapt(
.config(w: fill)
Row(
.config(gap: 20, yAlign: mid)
Text('Docs')
Text('Reference')
Text('Playground')
Text('Library')
Text('Changelog')
)
Row(.config(gap: 16, yAlign: mid) Text('Docs'), Text('Playground'))
Container(
.config(color: sunken, cornerRadius: 8, padding: sym(x: 12, y: 6))
.obj(Text('Menu'))
)
)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. | |
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). |
Slots
.objs: several objects, the default slot, required