Cranpose UI
Compose screens from text, buttons, fields, images and layout containers. Modifiers add size constraints, backgrounds, gestures, focus and accessibility semantics. Lazy lists compose rows as the viewport needs them.
App projects usually import this API through
cranpose::prelude.
Depend on cranpose-ui directly for a widget library or a custom host.
Build a reusable control
A composable accepts a callback. The caller supplies the save action; the control calls the callback after a click:
use ;
Call SaveButton from another composable. A platform host starts and drives the
composition. The Cranpose app example
shows desktop setup and state updates.
Choose a layout
| Task | API |
|---|---|
| Stack children vertically | Column |
| Place children in a horizontal row | Row |
| Overlay children | Box |
| Wrap children across rows | FlowRow |
| Compose a viewport from many items | LazyColumn, LazyRow |
| Define a measure policy | Layout and MeasurePolicy |
Modifier order affects geometry. For example,
Modifier::empty().padding(12.0).background(color) places the background inside
the outer space. Modifier::empty().background(color).padding(12.0) extends the
background across the control and its inner space.
Text, input and graphics
Use BasicTextField
with a retained TextFieldState for editable text. Use SelectionContainer for
selectable labels and LinkedText for annotated links. Canvas and
Modifier::draw_behind support custom graphics.
Controls contribute semantics for screen readers and tests. Custom controls add
roles, labels and actions through Modifier::semantics. Pointer, keyboard,
focus and rotary modifiers connect custom behavior to the same input system.
The optional svg feature enables SVG image support. inspection adds the
inspector data path. test-helpers serves framework tests. The default feature
set keeps these additions optional.
Read the layout guide for modifier and lazy-list examples, and the Liquid UI guide for styled controls and themes.