Field
将控件与标签、说明、验证状态和错误信息关联起来。
正在加载交互演示…
let field = Field::new("email");
field
.root().flex_col().gap(6.0)
.child(field.label_with(text("Email")))
.child(text_input(value))#导入
从 quickgui 导入 Field。
use quickgui::*;#用法
let field = Field::new("email");
field
.root().flex_col().gap(6.0)
.child(field.label_with(text("Email")))
.child(text_input(value))#结构
Field::rootField::itemField::labelField::controlField::validityField::descriptionField::error
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
Field
查看源码pub fn new(control_id: impl Into<ElementId>) -> Selfcontrol_idpub const fn control_id(&self) -> ElementId—
root_idpub fn root_id(&self) -> ElementId—
label_idpub fn label_id(&self) -> ElementId—
description_idpub fn description_id(&self) -> ElementId—
error_idpub fn error_id(&self) -> ElementId—
item_idpub fn item_id(&self) -> ElementId—
Stable identity of the item wrapper around one label/control/description row.
pub fn item_id(&self) -> ElementId查看源码validity_idpub fn validity_id(&self) -> ElementId—
statepub const fn state(&self) -> FieldState—
disabledpub fn disabled(mut self, disabled: bool) -> Self—
invalidpub fn invalid(mut self, invalid: bool) -> Self—
requiredpub fn required(mut self, required: bool) -> Self—
touchedpub fn touched(mut self, touched: bool) -> Self—
dirtypub fn dirty(mut self, dirty: bool) -> Self—
filledpub fn filled(mut self, filled: bool) -> Self—
validation_modepub const fn validation_mode(mut self, mode: FieldValidationMode) -> Self—
Declare when the controlled validity is expected to be recomputed, Base UI's `validationMode`.
pub const fn validation_mode(mut self, mode: FieldValidationMode) -> Self查看源码validation_debouncepub fn validation_debounce(mut self, debounce: Duration) -> Self—
Wait this long after a change before revalidating, Base UI's `validationDebounceTime`. The interval is an exact one-shot deadline the application schedules with [`crate::AsyncViewContext::sleep`]; QuickGUI never polls, and a field that is not being typed into owns nothing. It applies to [`FieldValidationTrigger::Change`] only — a blur or a submit is a deliberate boundary and validates immediately. Clamped to [`MAX_FIELD_VALIDATION_DEBOUNCE`].
pub fn validation_debounce(mut self, debounce: Duration) -> Self查看源码validation_mode_valuepub const fn validation_mode_value(&self) -> FieldValidationMode—
Configures validation mode value for this part.
pub const fn validation_mode_value(&self) -> FieldValidationMode查看源码validation_debounce_valuepub const fn validation_debounce_value(&self) -> Duration—
Configures validation debounce value for this part.
pub const fn validation_debounce_value(&self) -> Duration查看源码should_validatepub const fn should_validate(&self, trigger: FieldValidationTrigger) -> bool—
Whether the declared mode expects this event to recompute validity. A submit always validates; a blur validates on `OnBlur` and `OnChange`; a change validates only on `OnChange`.
pub const fn should_validate(&self, trigger: FieldValidationTrigger) -> bool查看源码validation_delaypub const fn validation_delay(&self, trigger: FieldValidationTrigger) -> Option<Duration>—
How long to wait before recomputing validity for this event, when it validates at all. Returns `None` when the declared mode ignores the event, and `Some(Duration::ZERO)` when it validates immediately, so a listener can branch once instead of re-deriving the policy.
pub const fn validation_delay(&self, trigger: FieldValidationTrigger) -> Option<Duration>查看源码validation_messagepub fn validation_message(mut self, message: impl Into<Arc<str>>) -> Self—
Retain the message used by form reports and native accessibility. The visible error part remains application-owned and can use different presentation copy.
pub fn validation_message(mut self, message: impl Into<Arc<str>>) -> Self查看源码validation_message_textpub fn validation_message_text(&self) -> Option<&str>—
Configures validation message text for this part.
pub fn validation_message_text(&self) -> Option<&str>查看源码validation_message_is_truncatedpub const fn validation_message_is_truncated(&self) -> bool—
Configures validation message is truncated for this part.
pub const fn validation_message_is_truncated(&self) -> bool查看源码Field::root_with
查看源码pub fn root_with(&self, root: Element) -> ElementDecorate an application-owned structural root without adding role or appearance.
Field::root
查看源码pub fn root(&self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Field::label_with
查看源码pub fn label_with(&self, label: Element) -> ElementDecorate a visible label and give it native label-to-control activation. Use [`Self::passive_label_with`] for button-like controls whose label should name but not activate them.
Field::label
查看源码pub fn label(&self) -> ElementCreate the unstyled label part. Use [`Self::label_with`] to supply an existing element.
Field::passive_label_with
查看源码pub fn passive_label_with(&self, label: Element) -> ElementDecorate a label relationship without forwarding pointer activation to the control.
Field::passive_label
查看源码pub fn passive_label(&self) -> ElementCreate the unstyled passive label part. Use [`Self::passive_label_with`] to supply an existing element.
Field::control_with
查看源码pub fn control_with(&self, control: Element) -> ElementDecorate the application-owned control with field state and mounted relationships.
Field::control
查看源码pub fn control(&self) -> ElementCreate the unstyled control part. Use [`Self::control_with`] to supply an existing element.
Field::item_with
查看源码pub fn item_with(&self, item: Element) -> ElementDecorate the caller-owned wrapper around one label/control/description row. Base UI's Field.Item groups the parts of a single field inside a larger fieldset so the row can be styled and laid out as one unit. QuickGUI supplies the stable identity and propagates the field's disabled state; layout and appearance stay application-owned.
Field::item
查看源码pub fn item(&self) -> ElementCreate the unstyled item part. Use [`Self::item_with`] to supply an existing element.
Field::validity_with
查看源码pub fn validity_with(&self, visible: bool, validity: Element) -> ElementDecorate a caller-owned part that is shown only for a chosen validity, Base UI's Field.Validity. `visible` is the application's own predicate over [`Self::state`] — "invalid and touched", "valid and dirty", whatever the product means. QuickGUI removes the part from layout, paint, input, and the accessibility tree when the predicate is false, exactly as [`Self::error_with`] does, so an unmatched validity costs nothing.
Field::validity
查看源码pub fn validity(&self, visible: bool) -> ElementCreate the unstyled validity part. Use [`Self::validity_with`] to supply an existing element.
Field::description_with
查看源码pub fn description_with(&self, description: Element) -> ElementDecorate visible supplementary help for the control.
Field::description
查看源码pub fn description(&self) -> ElementCreate the unstyled description part. Use [`Self::description_with`] to supply an existing element.
Field::error_with
查看源码pub fn error_with(&self, error: Element) -> ElementDecorate a visible error and remove it from layout while the controlled field is valid.
Field::error
查看源码pub fn error(&self) -> ElementCreate the unstyled error part. Use [`Self::error_with`] to supply an existing element.
