iced-cube

Forms

Field and label

Puts a label above any form control, with helper text or an error message below it.

use iced_cube::{field, label};
use iced_cube::forms::label::State;
API reference
Field: A label above a control, with a required marker or a description.Field: A label above a control, with a required marker or a description.
Static preview
Field. A label above a control, with a required marker or a description.

Usage

Use field for every form control so labels, descriptions and errors line up the same way across your app. The control keeps its own messages; field only lays it out.

When a field has an error, also mark the control itself as invalid (for example input(...).invalid(true)) so its border matches the message.

Clicking a label does not focus its control, and iced does not yet expose labels to screen readers, so keep label text short and visible next to the control it names.

Examples

Validation

An error message below the control turns the label destructive.

Validation: An error message below the control turns the label destructive.Validation: An error message below the control turns the label destructive.
Static preview

API

ItemDescription
field(label, control)Stacks a label above any control, such as an input, textarea or select.
.description(text)Adds muted helper text below the control.
.error(text) / .error_maybe(option)Shows an error below the control and colours the label to match. None clears it.
.required(bool)Adds a required marker after the label.
.disabled(bool)Mutes the label to match a disabled control.
.width(length)Overrides the width of the whole field. Fields fill the available width by default.
label(text)A standalone label, with .required(bool), .disabled(bool), .invalid(bool) and .state(State).
StateNormal, Disabled or Invalid. Sets the label's colour.
Esc