类型 Field

API 文档由 Go 源码生成,内容为英文。

type Field struct {
	// contains filtered or unexported fields
}

Field is a structural form recipe. It paints label, description, and error slots, then returns the rectangle reserved for the caller-owned control. It deliberately does not impersonate an input or own editor state.

构造函数

BeginField#

func BeginField(canvas *ui.Canvas, theme ui.Theme, bounds ui.Rect) Field

BeginField starts a vertical field group.

方法

Disabled#

func (field Field) Disabled() Field

Disabled mutes field metadata. The caller remains responsible for making the control painted into the returned slot inert.

For#

func (field Field) For(control ui.ID) Field

For makes the title the label of the control painted into the returned slot, as `htmlFor` does: pressing the title focuses and clicks the control (see ui.Canvas.HitLabel). The caller declares the control itself, with that identity.

Invalid#

func (field Field) Invalid() Field

Invalid applies destructive title and error semantics.

Orientation#

func (field Field) Orientation(orientation FieldOrientation) Field

Orientation selects vertical, horizontal, or width-responsive layout.

Paint#

func (field Field) Paint(title, description, errorText string) ui.Rect

Paint emits metadata slots and returns the control rectangle. Error is caller-deduplicated: avoiding a runtime map keeps paint deterministic and allocation-free while preserving Base UI's alert treatment. For several errors paint the control's slot yourself and use FieldError.

Required#

func (field Field) Required() Field

Required appends a destructive required marker to the title.