For the 0.6.0 to 0.7.0 changes, see UI 0.7.0 migration.
Arrange widgets
A settings screen might have a title, some content and action buttons. In rs_lvgl_ui, ordinary Rust functions describe those widgets; column, row and grid arrange them. LVGL handles layout and drawing.
The composition and forms guide covers lazy children, semantic callbacks, slots and typed bindings in 0.7.0.
Start with a column
The view below returns a title, a description and a button. column([...]) arranges them from top to bottom in collection order, and .gap(16) leaves 16 pixels between adjacent widgets.

Loading the interactive example…
Change gap(16) to gap(24), select Run and compare the spacing. You can also swap the title and description in the array and run it again.
This guide uses the 0.7.0 API. Import common functions and types with use rs_lvgl_ui::prelude::*. Constructors return a View<M> description; they do not create native widgets yet.
M is a generic parameter, like the familiar T, and its name is your choice. View<NotificationSettingsAction> means that this tree produces notification settings actions, such as toggling a switch or resetting it. State fields belong to the component struct, and the update method handles behavior; the action enum describes inputs. A view without actions can use View<()>.
Change the child order
A column places children in its normal flex flow from top to bottom.
column([
title,
content,
actions,
])- 0Title
- 1Content
- 2Actions
Variables name the parts. Their order inside column determines placement; styles determine sizes and spacing.
In column([title, content, actions]), the title appears first and the actions last. Arrays, vectors and iterators all preserve the supplied order; row lays out the same sequence horizontally. Sizes, spacing and alignment determine the pixel positions.
Extracting the title into a variable or function follows the same rule:
The code creates content before title, but the title appears first because it is the first item passed to column. A helper returns an ordinary View<M> and creates a fresh description on each call. It adds no state or cache. This is useful for reusing title styles; see Reuse components.
.child(node) appends one child; .children(items) appends several. container, row, column and grid are containers, as are tabview, tileview and message_box with their features enabled. Adding children to a button or label returns UiError::InvalidProperty before the native tree is changed.
Set sizes, spacing and alignment
Chain layout and style properties directly on the view. Common choices are:
content() sizes a widget to its content. .align(...) positions a widget in its parent; the three flex properties arrange its children and lines independently.
Place widgets in a grid
grid(columns, rows, children) takes column tracks, row tracks and children. Tracks use GridTrack::Px, Fr or Content. Each child uses .grid_cell(column, row, column_span, row_span) to set its position and span.

Loading the interactive example…
Change .grid_cell(...) to move a widget, or change the tracks to resize its available space. Swapping two items in the collection does not change their assigned cells. .grid_align(column, row) sets alignment within a cell. Tracks and cells are reapplied only when their descriptions change.
Style the widgets
Constructors initialize the view's embedded style description, so you can write label("Settings").font(theme.title_font).text_color(theme.text) directly. The font and text color explicitly come from the current theme. Ui::set_theme requests a new view on the next update, when the new tokens are read; a previously saved style value does not track later theme changes.
Set .font(theme.body_font).text_color(theme.text) on the root to let body text inherit the theme and remain readable in both light and dark modes.
Extract repeated properties into a style() patch and merge it with .style(patch):
Properties follow call order: the last explicit value wins, including 0 and false. Unset patch fields preserve previous values or inheritance. background also sets background opacity to 255; call .background_opacity(...) after it for translucency.
style() returns a patch with every field unset. Style::default() is the equivalent Rust value-construction primitive; ordinary views do not need to call it. Style::plain() explicitly writes base layout and appearance values; it is neither an empty patch nor a complete reset. Extended fields remain unset. Containers and labels apply those base values automatically while text color, font and alignment inherit. Use Style::screen(theme), surface(theme) and accent(theme) for themed screens, panels and action buttons, then override individual properties directly. The accent preset clears native shadows; plain buttons retain the native theme's surface and shadow.
These modifiers update the existing style value without a heap allocation for each property. Child collections, owned text, event closures and reconciliation can still allocate. The runtime manages native style resources during mount, update and unmount. See Mount and update for memory and lifetime boundaries.
Use .state_style(State::PRESSED, style().opacity(200)) or the corresponding State::FOCUSED selector for interaction states. LVGL switches the local style while it holds the state, without enqueuing an action or rebuilding the view.
Give list items stable keys
When a list can insert, remove or reorder items, use Key::Id(item.id) to identify each item. The key follows the item; collection order determines placement. An array index follows a position and cannot identify an item after reordering.
The colors identify the same siblings before and after a reorder.
Id(10)Id(20)Id(30)Id(20)Id(30)Id(10)The collection sets the new order. Stable keys and compatible widget kinds allow native objects to survive the move. Auto keys match positions among Auto siblings.
Key identifies a child among its siblings:
Key::Auto(default) matches by position among theAutosiblings.Key::Named(&'static str)matches by a static name.Key::Id(u64)matches by an application identifier.
Named and ID keys must be unique among siblings; duplicates fail validation with UiError::DuplicateKey. Named takes a &'static str, so identifiers generated at runtime use Key::Id. Keyboard IDs are looked up across the view and overlay, so they should be unique across both trees.
Keys make list updates local:
Which native widgets are reused during an update?
On each render, the reconciler matches keyed children by value and auto children by position. It reuses a native object when the key and widget kind are unchanged, writes changed properties and styles in place, creates new children, deletes removed ones and reorders survivors. The reorder keeps a longest increasing subsequence of current positions, so only children outside it move. A key change, a widget-kind change, a custom-widget variant change, or a structural property that LVGL cannot patch replaces that native subtree. The root and tab pages follow the same identity rule.
For a keyed list, changing one item's text updates one native label; appending one row creates one subtree; moving one row moves it without recreating its neighbors. Native identity also preserves focus and scroll position while the node stays in the tree and remains eligible. Ui::stats reports created_nodes, deleted_nodes and moved_nodes.
Read application state in the view
When a title, switch value or list changes, App::view returns a new View<DeviceListAction>. View<M> is an alias for Node<M>, so helpers and built-in constructors return the same type.
Settings owns application state, NotificationSettingsAction describes notification settings actions, and App defines update rules. Ui borrows the app to process actions and reconcile View descriptions into native objects.
Open full-size diagram ↗Settings.enabled and Settings.changes in the diagram come from the switch example. update changes those fields, and view uses them to describe the widgets. Ui borrows the app to apply an update; the state remains in the application struct. Next, connect input to the screen. See Mount and update for the platform loop and cleanup.