A single or multiline text field with its label above. It handles IMEs, ruby, vertical text and undo. A multiline field grows with its text where nothing sets its height, and fills the height that an Expanded or the like gives it, with or without a label. With SubmitOnEnter, a multiline field sends on Enter and breaks the line on Shift+Enter, as the box of a chat does. Autofocus gives it the keyboard when it first appears, also in a dialog. For long documents, use editor.Editor.
set:=func(string){}returnbasic.SizedBox{Width:300,Height:260,Child:basic.Column{Cross:layout.CrossStretch,Spacing:theme.Space16,Children:[]core.Widget{field.Input{Label:"Name",Value:"Hanako Yamada",OnChange:set},field.Input{Label:"Email",Placeholder:"name@example.com",OnChange:set},basic.Expanded{Child:field.Input{Label:"Notes",Multiline:true,Value:"A multiline field fills the height\nthat an Expanded gives it.",OnChange:set,}},}}}
cities:=[]string{"Amsterdam","Athens","Berlin","Lisbon","Madrid","Paris","Prague","Rome"}returnbasic.SizedBox{Width:260,Child:field.Autocomplete[string]{Label:"City",Placeholder:"Type a city",Options:cities,OnSelect:func(string){},}}
An editor for code and long text, with line numbers, decorations and find and replace. It lays out only the lines in view. While the find bar is open, the text keeps the room of the bar above its first line, and a match shows below the bar. Lines given through Controller.SetSource, as of a file, are read only where they are in view, and only the lines edited are held in memory, so that a file of gigabytes opens at once.
A field for a number, typed or stepped with the arrow keys, the wheel while it has the focus, or a drag of the handle at its end. It takes full-width digits, and the separators follow the locale. Enter takes the typed text as the value; inside a FormItem it then submits the Form around with the new value, and outside one it submits nothing.
Edits a list of short texts such as tags or addresses, each shown as a chip. Enter or a separator makes a token, but not while an IME converts. Two Backspaces at the start remove the last token.
field.TokenField{Label:"Tags",Tokens:[]string{"design","go","typography"},Placeholder:"Add a tag",OnChange:set},field.TokenField{Label:"Disabled",Tokens:[]string{"read only"}},
Checks and submits the FormItems below it together. Errors show below the fields, whose borders turn red, on submit and when a field loses the focus. The error of Required follows the control inside: Required for a text field, Choose one for a choice such as a DropdownMenu or a DatePicker, Check this box for a Checkbox; RequiredMessage replaces it. Enter in a single-line field of a FormItem submits the form.
varformfield.FormControlleremail:=regexp.MustCompile(`[^@\s]+@[^@\s]+\.[^@\s]+`)returnbasic.SizedBox{Width:280,Child:field.Form{Controller:&form,Child:basic.Column{Size:layout.MainMin,Cross:layout.CrossStretch,Spacing:theme.Space12,Children:[]core.Widget{field.FormItem[string]{Required:true,Child:field.Input{Label:"Name",OnChange:func(string){}}},field.FormItem[string]{Value:"taro@",Validators:[]func(string)string{field.Pattern(email,"Enter an address like name@example.com")},Child:field.Input{Label:"Email",Value:"taro@",OnChange:func(string){}},},field.FormItem[time.Time]{Required:true,Child:field.DatePicker{Label:"Birth date",Placeholder:"Choose a date",OnChange:func(time.Time){},InitialMonth:time.Date(1995,time.January,1,0,0,0,0,time.UTC),}},field.FormItem[bool]{Required:true,Child:control.Checkbox{Label:"I agree to the terms",OnChange:func(bool){}}},basic.Row{Main:layout.MainEnd,Children:[]core.Widget{control.Button{Label:"Create account",Style:control.ButtonPrimary,OnPress:func(){form.Submit()}},}},},}}}