⌂
›
Reference
›
Controls and Layout
Controls and Layout
Ruflet interfaces are trees of controls built with Ruby helper methods.
page.add(
safe_area(
container(
expand: true,
padding: 24,
content: column(
spacing: 16,
children: [
text("Profile", size: 28, weight: "bold"),
text_field(label: "Display name"),
row(
spacing: 12,
children: [
filled_button(content: text("Save")),
outlined_button(content: text("Cancel"))
]
)
]
)
)
)
)
Composition
columnlays out children vertically.rowlays out children horizontally.containeradds size, spacing, alignment, decoration, and one content control.stackoverlays positioned children.list_viewandgrid_viewprovide scrolling collections.safe_areaavoids operating-system display cutouts and insets.
Most controls use children: for a list or content: for one nested control. Some compatibility helpers also accept controls:.
Sizing
expand: truefills available space along the parent's main axis.widthandheightrequest fixed dimensions.paddingadds space inside a control.marginadds space around a control.spacingcontrols gaps between row or column children.
Use page.client_details when a layout must respond to client width, height, or platform.
Updating controls
Keep a reference to controls that change:
status = text("Ready")
page.add(status)
page.update(status, value: "Saved")
For large state changes, rebuild the relevant view or replace page.views. For small changes, patch the mounted control with page.update.
Control families
Ruflet includes Material and Cupertino controls, form inputs, navigation surfaces, lists, tables, charts, maps, media controls, and drawing primitives. Browse Controls for individual properties and events.