Form controls
PreviewCheckboxes, switches, radio groups, segmented controls, sliders, number fields, search fields and form rows, drawn by Pitwall with the controls of its own Settings and dialogs, in the user's theme. Anything Pitwall's own screens draw, a tile draws the same way ("kit parity", ui.md §3.10).
The examples come from the gallery tile Pitwall's tests run (the Form controls page of crates/pitwall-tile-host/tests/fixtures/hello-tile/src/widgets.rs); the screenshots are that tile drawn headless, dark and light. Other component groups: Feedback, Layout, Data display, Charts, and the lists, tables and menus in Tiles and UI components.
What every control shares:
- Controlled. A control shows the value the tile gives it. The user's change comes to its
on_changelistener asvalue-changed; set your state, callcx.notify(), and the next frame shows it. A control without a listener can't be changed. Text fields are the exception: Pitwall owns what is typed (Text fields). - Keyboard and focus. Each enabled control is a Tab stop with Pitwall's focus ring. A disabled one is skipped and can't be changed by click or key.
- Accessibility. The label is the accessible name;
.label("…")names a control that has none (a radio group, a slider)..tooltip("…")works on all of them. - Limits. Over a limit, the tile stops with the reason, as for any frame (Limits).
- Tests.
pitwall-extension-testdrives each control as the user would, with the host's own rules for clicks and keys, so the harness and Pitwall agree.
- Checkbox
- Switch
- Radio group
- Segmented control
- Slider
- Number field
- Search field
- Form row
- Disabled and read-only
- Secure field
- Host-owned setting field
Checkbox

An option the user turns on or off, usually among others in a form or a filter. Use a switch instead for a setting that takes effect at once.
let boxes = v_flex()
.gap_2()
.child(checkbox("Only failures").id("failures").checked(self.only_failures).on_change(cx.listener(|t: &mut Hello, on: &bool, cx| {
t.widgets.only_failures = *on;
cx.notify();
})))
// Some of a group on: a dash; a click turns them all on.
.child(checkbox("All branches").id("branches").checked(some == Some(true)).mixed(some.is_none()).on_change(cx.listener(|t: &mut Hello, on: &bool, cx| {
t.widgets.all_branches = Some(*on);
cx.notify();
})));
| Option | What it does |
|---|---|
checkbox(label) | A checkbox with its label; the label is clickable too |
.checked(bool) | On |
.mixed(bool) | Some of a group on: drawn with a dash. A click turns it on |
.disabled(bool) | Drawn dimmed; no clicks, no Tab stop |
.on_change(listener) | Hears the new state (&bool) |
- Events.
value-changedwithon(bool): the other state, oron(true)from mixed. - Keyboard. Space toggles it.
- Accessibility. Its label is its name.
- Test.
t.toggle("key");t.key_on("key", "space").
Switch

An on/off setting that applies right away, as Pitwall's Settings use them. The same options and events as a checkbox, without mixed.
let notify = switch("Notify me when a run fails").id("notify").checked(self.notify).on_change(cx.listener(|t: &mut Hello, on: &bool, cx| {
t.widgets.notify = *on;
cx.notify();
}));
| Option | What it does |
|---|---|
switch(label) | A switch with its label |
.checked(bool), .disabled(bool), .on_change(listener) | As for a checkbox |
- Events.
value-changedwithon(bool). - Keyboard. Space toggles it.
- Test.
t.toggle("key").
Radio group

One of a few choices, all in sight, stacked: up to about six, when each needs words. For more, or less room, use a select; for two to four short ones side by side, a segmented control.
let scope = radio_group()
.id("scope")
.label("Which runs")
.option("all", "All runs")
.option("mine", "My runs")
.option("failed", "Failed runs")
.selected(self.scope.clone())
.on_change(cx.listener(|t: &mut Hello, key: &str, cx| {
t.widgets.scope = key.to_string();
cx.notify();
}));
| Option | What it does |
|---|---|
radio_group() | An empty group |
.option(key, label) | A choice; key is what the tile hears |
.option_disabled() | The last option added can't be chosen |
.selected(key) | The chosen option |
.horizontal() | Side by side instead of stacked |
.disabled(bool) | The whole group |
.on_change(listener) | Hears the chosen key (&str) |
- Events.
value-changedwithchoice(key). - Keyboard. One Tab stop for the group. The arrow keys move the choice (skipping disabled options, wrapping), Home and End go to the first and last, Space chooses the first when none is.
- Accessibility. Name the group with
.label("…"); each option's label is its name. - Limits. 64 options; keys unique.
- Test.
t.choose("key", "option");t.key_on("key", "down").
Segmented control

Two to five short choices side by side: a range (Day, Week, Month), a view mode. It is drawn with the same segmented control as tabs, Pitwall's own. Tabs switch what the tile shows and send select; a segmented control is a form value: it sends value-changed, and options and the whole control can be disabled.
let range = segmented()
.id("range")
.label("Range")
.option("day", "Day")
.option("week", "Week")
.option("month", "Month")
.selected(self.range.clone())
.on_change(cx.listener(|t: &mut Hello, key: &str, cx| {
t.widgets.range = key.to_string();
cx.notify();
}));
| Option | What it does |
|---|---|
segmented() | An empty control |
.option(key, label), .option_disabled(), .selected(key), .disabled(bool), .on_change(listener) | As for a radio group |
- Events.
value-changedwithchoice(key). - Keyboard. As a radio group: Left and Right move the choice, wrapping.
- Accessibility. Name it with
.label("…"). - Limits. 64 options; keys unique.
- Test.
t.choose("key", "option");t.key_on("key", "right").
Slider

A number in a range where the exact value matters less than where it sits: a volume, an opacity, a threshold. For an exact number, use a number field.
let volume = slider(self.volume, 0.0..=100.0).id("volume").label("Volume").step(5.0).show_value().w(px(240.)).on_change(cx.listener(|t: &mut Hello, v: &f64, cx| {
t.widgets.volume = *v;
cx.notify();
}));
| Option | What it does |
|---|---|
slider(value, min..=max) | A slider at value |
.step(n) | Values snap to min + k·n; 0 (the default) is any value |
.show_value() | The value drawn beside it |
.disabled(bool) | No dragging, no Tab stop |
.on_change(listener) | Hears the value (&f64) |
- Events.
value-changedwithnumber(f64), kept in the range and snapped to the step. While the user drags, Pitwall draws the thumb itself and sends at most one value every 50 ms, and always the last one when they let go. - Keyboard. Left and Down step down, Right and Up step up (a step, or a hundredth of the range), Page Up and Page Down by a tenth of the range, Home and End to the ends.
- Accessibility. Name it with
.label("…"). - Limits.
minbelowmax, both finite; the step 0 or more. - Test.
t.set_slider("key", 73.0)(snapped as Pitwall snaps);t.key_on("key", "end").
Number field

An exact number: retries, a port, a timeout. A text field with − and + steps; Pitwall checks what is typed and keeps it within the bounds.
let retries = number_field(self.retries).id("retries").label("Retries").min(0.).max(10.).placeholder("None").w(px(140.)).on_change(cx.listener(|t: &mut Hello, v: &Option<f64>, cx| {
t.widgets.retries = *v;
cx.notify();
}));
| Option | What it does |
|---|---|
number_field(Option<f64>) | A field holding the number, or empty |
.min(v), .max(v) | The bounds; a number typed past one is kept at it |
.step(n) | What − and + add (default 1) |
.decimals(n) | Decimal places shown and kept (0–6, default 0) |
.placeholder(text) | Shown while empty |
.readonly(bool) | Shown, selectable, not changed |
.disabled(bool) | Dimmed, no Tab stop |
.on_change(listener) | Hears &Option<f64>: the number, or None when emptied |
- Events.
value-changedwithnumber(f64), oremptywhen the user clears it. A typed number is sent on Enter or when the field loses focus; text that isn't a number puts the old value back and sends nothing. A comma works as the decimal point. - Keyboard. Up and Down step; an empty field steps to its min (or 0). Typing as in any text field.
- Accessibility. Name it with
.label("…")or a form row. - Limits. The step above 0;
minat mostmax; all finite. - Test.
t.type_number("key", "12")(returns whether it sent anything);t.step_number("key", true);t.key_on("key", "up").
Search field

Filter text above a list or a table: a text field with a magnifier and a clear button, as Pitwall's own lists have.
let search = search_field("query").placeholder("Filter branches").on_change(cx.listener(|t: &mut Hello, q: &str, cx| {
t.widgets.query = q.to_string();
cx.notify();
}));
| Option | What it does |
|---|---|
search_field(key) | A search field; it takes the same options as input(key): .placeholder, .value, .disabled, .on_change, .on_submit |
- Events. As a text field's:
input-changedwhile the user types (at most one every 50 ms),submiton Enter. The clear button empties it and sendsinput-changedwith"". - Keyboard. As a text field. The clear button is shown only while it has text.
- Limits. As a text field: 1 MiB of text.
- Test.
t.type_into("key", "fix");t.clear_search("key");t.field_text("key").
Form row

A control with its label, help text, validation message and required mark, laid out as Pitwall's Settings and dialogs lay theirs out. Use one for every field of a form, so forms in tiles read like Pitwall's.
let branch = form_row("Branch")
.id("branch-row")
.required()
.help("Runs start from this branch")
.error(missing.then_some("Name a branch"))
.child(input("branch").placeholder("main").on_change(cx.listener(|t: &mut Hello, v: &str, cx| {
t.widgets.branch = v.to_string();
cx.notify();
})));
let retries = form_row("Retries").id("retries-row").inline().child(number_field(self.retries).id("retries").min(0.).max(10.).w(px(120.)));
| Option | What it does |
|---|---|
form_row(label) | A row; its children are the control |
.help(text) | A line under the control |
.error(Option<text>) | The validation message, in red; None hides it |
.required() | A required mark after the label |
.inline() | The label beside the control instead of above |
- Events. None of its own; the control's.
- Accessibility. The label names the control under it; the error is read with it.
- Test. The snapshot shows
form-row "Branch" required help=… error=….
Disabled and read-only

Every control has .disabled(true): drawn dimmed, no clicks, no keys, no Tab stop. A number field and a text field also have read-only (.readonly(true) on a number field): the value is shown and can be selected and copied, but not changed. Say why something is disabled near it (a form row's help, a tooltip) when it isn't plain.
let off = v_flex()
.gap_2()
.child(checkbox("Can't change this").id("box").checked(true).disabled(true))
.child(switch("Turned off by your admin").id("switch").disabled(true))
.child(segmented().id("seg").option("a", "On").option("b", "Off").selected("a").disabled(true))
.child(slider(40., 0.0..=100.0).id("slider").disabled(true).w(px(200.)))
.child(number_field(Some(3.)).id("number").readonly(true).w(px(120.)))
.child(input("locked").value("Read only").disabled(true).w(px(200.)));
- Test. The snapshot shows
disabledandreadonly; the harness panics when a test changes a disabled control, as the user can't.
Secure field
A Setup view places secret_field(key) where the user sets a declared secret setting. Pitwall owns this field: it masks typing, saves on Enter or blur, and offers Paste, Replace and Remove. The saved value is never drawn or sent to the component. Its appearance is host-controlled.
secret_field("apiKey").id("api-key").placeholder("API key")
Use settings::secret_set("apiKey") to learn whether it is set, and Event::SecretChanged { key, set } to react to a save or removal. There is no value or text-change listener on a secure field. Ordinary input fields are for non-secret text and send their changes to the component. A field naming a key that is not a declared secret shows an error instead of accepting input.

Tests use session.enter_secret("api-key", Some("test-key")) (or None to remove it); snapshots include only the key and set/unset state.
Host-owned setting field

Use setting_field("server") in the Setup view for a manifest setting, especially a URL used by a network grant. Pitwall supplies the saved value, owns the input, validates and saves it on Enter or blur. The component supplies only the schema key and an optional placeholder:
setting_field("server").id("server-field").placeholder("https://example.com")
It has no component change listener and accepts no component-supplied value. Unknown or secret schema keys show an error instead of an input. A URL that supplies a network host follows the network permission's transport rules (HTTPS, or HTTP to loopback). A valid edit updates an already-granted dynamic host; an explicit network refusal remains refused.
The component hears Event::SettingsChanged(Some(key)) after a save. For ordinary settings drawn with your own controls, use settings::set(key, settings::Value::Text(value)) instead; secrets and grant-bearing keys are denied. Test the host-owned path with t.enter_setting("server-field", "https://example.com").