4. Arrange the controls

Your development computer

Choose the computer you’ll build on. Your choice applies throughout these six lessons.

Add a reset button and a horizontal button row to the app from lesson 3.

1. Add the layout messages

Append to resource/locales/en/app.ftl:

Append to resource/locales/en/app.ftl:

reset_count = Reset
session_hint = Add one after each session. Reset when you start a new day.

2. Compose the layout

Replace src/lib.rs:

Write src/lib.rs:

use day::prelude::*;

day::resources!();
day::day_start!(options: res::window_options(), root);

pub fn root() -> impl Piece {
    let count = Signal::new(0i64);

    column((
        label(res::str::welcome()),
        label(res::str::counter_value(count)).id(id!(counter_label)),
        row((
            button(res::str::add_one())
                .action(move || count.update(|n| *n = n.saturating_add(1)))
                .id(id!(increment_button)),
            button(res::str::reset_count())
                .action(move || count.set(0))
                .id(id!(reset_button)),
        ))
        .spacing(Space::M),
        label(res::str::session_hint()),
    ))
    .spacing(Space::M)
    .padding(Space::L)
    .grow(Dimension::Both)
}

row arranges children horizontally; column arranges them vertically. Both accept tuples of Pieces. .spacing separates siblings; .padding adds space around content. .grow(Dimension::Both) uses available width and height. Labels wrap by default. Space::M and Space::L are spacing tokens.

set(0) resets the shared count.

3. Resize and reset

macOS

day launch -t macos-appkit

Windows

day launch -t windows-winui

Linux

day launch -t linux-gtk

macOS

Quit with Command-Q before continuing.

Windows

Close the app window before continuing.

Linux

Close the app window before continuing.

Press Add one twice, then Reset; expect Count: 0. Check initial and minimum window sizes: buttons remain in one row, and the hint wraps as needed. Quit before editing.

Troubleshooting

If buttons stack, place them in row((...)). If the hint is clipped, check available space and manifest minimum dimensions. Test longer translations at minimum size.

Next step

Continue to 5. Navigate between pages.