Shows a string broken into lines by the rules of its Style, with Japanese line breaking, vertical text and justification. Style.MaxLines cuts it short with an ellipsis; a screen reader still reads it whole.
themed(func(th*theme.Theme)core.Widget{returnbasic.SizedBox{Width:340,Child:basic.Column{Size:layout.MainMin,Cross:layout.CrossStart,Spacing:theme.Space6,Children:[]core.Widget{basic.Text{Content:"Large title",Style:th.Text.LargeTitle},basic.Text{Content:"Title",Style:th.Text.Title},basic.Text{Content:"Body text breaks into lines by the rules of its style, and the line height stays on an even grid."},basic.Text{Content:"Caption in the secondary ink",Style:colored(th.Text.Caption,th.Color.Ink2)},// MaxLines cuts the text short with an ellipsis.basic.Text{Content:"A one-line preview of a long message that does not fit in the row",Style:th.Text.Body.WithMaxLines(1)},}}}})
Mixes spans of different looks in one paragraph, with ruby and emphasis dots, and a Background behind a span, such as a match of a search. Style.MaxLines works as for Text.
themed(func(th*theme.Theme)core.Widget{c:=&th.Colorreturnbasic.SizedBox{Width:320,Child:basic.RichText{Style:colored(th.Text.Body,c.Ink).WithMaxLines(2),Spans:[]text.Span{{Text:"Rich text mixes "},{Text:"accented",Style:colored(th.Text.Body,c.AccentInk)},{Text:", "},{Text:"bold",Style:colored(th.Text.Body,c.Ink).WithWeight(700)},{Text:", "},{Text:"large",Style:text.Style{Size:20,Color:c.Ink}},{Text:", "},{Text:"quiet",Style:colored(th.Text.Caption,c.Ink2)},{Text:" and "},{Text:"highlighted",Background:c.Warning.WithAlpha(0.35)},{Text:" runs in one paragraph that wraps, and stops after two lines with an ellipsis."},}}}})
Draws a vector shape on a 24 unit grid. Without a Label it is decorative. Package icons holds 24 common shapes: folder, file, search, close, chevrons, gear, trash and more.
themed(func(th*theme.Theme)core.Widget{// The stock icons of package icons. Build them once and keep them, as// in InitState: each call makes a new path.set:=[]*paint.Path{icons.Folder(),icons.File(),icons.Document(),icons.Image(),icons.Search(),icons.Plus(),icons.Minus(),icons.Close(),icons.Check(),icons.ChevronLeft(),icons.ChevronRight(),icons.ChevronUp(),icons.ChevronDown(),icons.Settings(),icons.Trash(),icons.Edit(),icons.Copy(),icons.Home(),icons.Star(),icons.Info(),icons.Warning(),icons.Error(),icons.Menu(),icons.More(),}stock:=make([]core.Widget,len(set))fori,p:=rangeset{stock[i]=basic.Icon{Path:p,Color:th.Color.Ink2}}returnbasic.Column{Size:layout.MainMin,Cross:layout.CrossStart,Spacing:theme.Space20,Children:[]core.Widget{basic.Row{Size:layout.MainMin,Spacing:theme.Space16,Cross:layout.CrossCenter,Children:[]core.Widget{basic.Icon{Path:set[0],Color:th.Color.AccentInk,Label:"Folder"},basic.Icon{Path:set[18],Size:32,Color:th.Color.Danger},basic.Icon{Path:set[8],Size:16,Color:th.Color.Success},basic.Icon{Path:circleIcon(),Color:th.Color.Ink2},// a path of your own}},basic.SizedBox{Width:400,Child:basic.Wrap{Spacing:theme.Space16,RunSpacing:theme.Space16,Children:stock}},}}})
picture:=photo()// paint.NewImage of an image.Image, made once and keptreturnbasic.Row{Size:layout.MainMin,Spacing:theme.Space16,Children:[]core.Widget{basic.Image{Source:picture,Width:160,Label:"Hills under a clear sky"},basic.Image{Source:picture,Width:100,Height:100,Fit:layout.FitCover,Radius:50},basic.Image{Source:picture,Width:48,Height:48,Quality:paint.FilterNearest},}}
basic.Row{Size:layout.MainMin,Spacing:theme.Space16,Cross:layout.CrossStart,Children:[]core.Widget{basic.SizedBox{Width:200,Child:control.Card{Label:"Summary",Child:basic.Column{Size:layout.MainMin,Cross:layout.CrossStart,Spacing:theme.Space6,Children:[]core.Widget{basic.Text{Content:"Summary"},basic.Text{Content:"A plain card holds one piece of content."},},}}},basic.SizedBox{Width:200,Child:control.Card{Label:"Open note",OnPress:func(){},Child:basic.Column{Size:layout.MainMin,Cross:layout.CrossStart,Spacing:theme.Space6,Children:[]core.Widget{basic.Text{Content:"Pressable"},basic.Text{Content:"With OnPress the whole card is a button."},},}}},}}
A header that opens and closes the content below it. Closed content is not laid out, and Tab and assistive technology pass it by. With OnChange the parent keeps the state, which makes several in a row an accordion.
control.Disclosure{Title:"Advanced",Child:basic.Text{Content:"Closed, the content is not laid out.",Style:note}},control.Disclosure{Title:"Sync",Open:true,Child:basic.Text{Content:"Open starts it open. Without OnChange it keeps its own state.",Style:note,}},control.Disclosure{Title:"Notifications",Header:basic.Row{Size:layout.MainMin,Spacing:theme.Space6,Children:[]core.Widget{basic.Text{Content:"Notifications",Style:th.Text.Headline},control.Badge{Count:3},}},Child:basic.Text{Content:"A header can hold a badge.",Style:note}},
Shows its child through a pan and a zoom: drag to move, Ctrl with the wheel or a pinch to zoom about the pointer. WheelZooms zooms with the plain wheel, as image viewers do. The arrow keys pan only while there is room to, and otherwise go on to the shortcuts of the app; Keys leaves them out, or keeps the viewer out of the focus. The child is laid out once, and the buttons in it keep working. ViewerController moves the view from outside.
varviewinteract.ViewerControllerview.Fit(false)// once the viewer knows its sizereturnbasic.SizedBox{Width:440,Height:280,Child:basic.Container{Radius:th.Radius.Control,Border:paint.Stroke{Width:1,Color:th.Color.Hair},Child:interact.InteractiveViewer{Controller:&view,MinScale:0.2,MaxScale:6,BoundaryMargin:16,DoubleTapZoom:true,Label:"Drawing",Child:drawing,},}}
basic.SizedBox{Width:300,Child:basic.Column{Size:layout.MainMin,Cross:layout.CrossStretch,Spacing:theme.Space12,Children:[]core.Widget{basic.Text{Content:"Above the line"},basic.Divider{},basic.Text{Content:"Indented line below"},basic.Divider{Indent:theme.Space16},basic.Row{Size:layout.MainMin,Spacing:theme.Space12,Children:[]core.Widget{basic.Text{Content:"Left"},basic.SizedBox{Height:20,Child:basic.Divider{Axis:layout.Vertical}},basic.Text{Content:"Right"},}},}}}
basic.Row{Size:layout.MainMin,Cross:layout.CrossCenter,Spacing:theme.Space24,Children:[]core.Widget{basic.SizedBox{Width:140,Height:28,Child:control.Sparkline{Data:trend,Fill:true,MarkLast:true,Label:"Temperature, now 21.4 degrees",}},basic.SizedBox{Width:120,Height:28,Child:control.Sparkline{Kind:control.SparklineBars,Data:change}},}}