form
Builds Combobox FormField NumberInput SegmentedControl TagInput TextInput


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn form(window: &mut Window, cx: &mut App) -> AnyElement {
ensure_form(window, cx);
let form = cx.global::<SceneForm>();
let (name, retention, region, labels) = (
form.name.clone(),
form.retention.clone(),
form.region.clone(),
form.labels.clone(),
);
let theme = cx.theme().clone();
stack(&theme)
.w(px(420.0))
.h(px(720.0))
.child(
FormField::new("scene.form.name.field", "Workspace name")
.control("scene.form.name")
.required(true)
// The description says what the field is for and the error
// says what went wrong; neither answers for the other.
.description("Shown wherever this workspace appears.")
.error("A workspace with this name already exists.")
.child(name),
)
.child(
FormField::new("scene.form.retention.field", "Retention")
.control("scene.form.retention")
.required(true)
.description("How long a finished run is kept.")
.error("This workspace allows at most 60 days.")
.child(retention),
)
.child(
FormField::new("scene.form.visibility.field", "Visibility")
.control("scene.form.visibility")
.description("Who can open the runs in this workspace.")
.child(
SegmentedControl::new("scene.form.visibility")
.label("Visibility")
.segments([
Segment::new("private", "Private"),
Segment::new("team", "Team"),
Segment::new("public", "Public").disabled(true),
])
.selected("team")
.on_select(|_, _, _| {}),
),
)
.child(
FormField::new("scene.form.labels.field", "Labels")
.control("scene.form.labels")
// The keystroke lives in the hint, so the description does not
// spend a second line repeating it.
.description("At most five, and each one only once.")
.hint("enter")
.child(labels),
)
.child(
FormField::new("scene.form.region.field", "Region")
.control("scene.form.region")
.description("Where runs in this workspace are executed.")
.child(region),
)
.into_any_element()
}