Field
Label, helper, error and required — around any control.
Field is the form-field wrapper: it adds the label above, helper or
error text below, and the required marker — around any control (Input, Select,
Checkbox, a custom widget). The control knows nothing about it; composition, not slots.
Installation
Use the module import (the default), or own the source: lotusui add
vendors the component into your app and lotusui update keeps the copy mergeable —
see Registry.
go get github.com/ikaito-com/lotusui
# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add field
Usage
lotusui.Field(th, lotusui.FieldOpts{Label: "Email"}, func(gtx C) D {
return email.LayoutField(th, gtx, "you@example.com")
})
Helper text
Helper renders muted guidance under the control.
lotusui.FieldOpts{Label: "Email", Helper: "We'll never share it."}
Required
Required marks the label; validation stays yours.
lotusui.FieldOpts{Label: "Email", Required: true}
Error
Error replaces the helper with the message in danger ink — pair it
with the control's own invalid chrome.
lotusui.FieldOpts{Label: "Workspace name", Error: msg}
Any control
The wrapped control is any layout.Widget — here a Select.
lotusui.Field(th, lotusui.FieldOpts{Label: "Role"}, func(gtx C) D {
return role.Layout(th, gtx, "")
})
API
| Option | Type | Description |
|---|---|---|
Label | string | The label above the control. |
Helper | string | Muted guidance below; recomputed each frame (counters). |
Error | string | Replaces Helper in danger ink. |
Required | bool | Marks the label. |