lotusui the ikaito design language for Gio — desktop, mobile, web
GitHub

Toggle

The pressed-state button, and groups with single or multiple selection.

Toggle stays filled while On; clicking flips it. ToggleGroup coordinates a row — radio semantics by default (Sel), independent bools with Multiple.

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
go get github.com/ikaito-com/lotusui

# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add toggle

Usage

Go
var bold lotusui.Toggle
bold.Layout(th, gtx, lotusui.ToggleProps{Icon: lotusui.IconTextBold})
if bold.On { /* … */ }

ToggleGroup — single

Go
format := lotusui.ToggleGroup{Options: []lotusui.ToggleOption{
	// Icon-only options MUST carry a Value — an empty Label has none.
	{Value: "bold", Icon: lotusui.IconTextBold},
	{Value: "italic", Icon: lotusui.IconTextItalic},
	{Value: "underline", Icon: lotusui.IconTextUnderline},
}}
format.Layout(th, gtx, lotusui.SizeMD)
active := format.Value() // "italic"

ToggleGroup — multiple

Go
marks := lotusui.ToggleGroup{Multiple: true, Options: []lotusui.ToggleOption{
	{Label: "Bold", Value: "bold", Icon: lotusui.IconTextBold},
	{Label: "Italic", Value: "italic", Icon: lotusui.IconTextItalic},
}}
marks.SetValues(stored)
stored = marks.Values() // in Options order

Sizes

Go
small.Layout(th, gtx, lotusui.ToggleProps{Label: "Small", Outline: true, Size: lotusui.SizeSM})

Disabled

Go
t.Layout(th, gtx, lotusui.ToggleProps{Label: "Disabled", Disabled: true})

Group outline

Go
var g = lotusui.ToggleGroup{Sel: 0, Outline: true}

Group sizes

The size is the Layout parameter — the whole group moves together.

Go
g.Layout(th, gtx, lotusui.SizeSM, items...)

Group disabled

Go
var g = lotusui.ToggleGroup{Multiple: true, Disabled: true}

Group vertical

Go
var g = lotusui.ToggleGroup{Multiple: true, Vertical: true, Spacing: 1}

Group spacing

Spacing overrides the 2dp gap between items.

Go
var g = lotusui.ToggleGroup{Sel: 0, Outline: true, Spacing: 8}

Font weight selector

Content replaces Icon/Label with arbitrary content inside the item's chrome — composed here with a Field.

Go
lotusui.ToggleOption{Value: "bold", Content: weightCell("Aa", "Bold", font.Bold)}

API

OptionTypeDescription
OnboolThe pressed state — yours; clicking flips it.
Icon / LabelstringOne or both.
Contentlayout.WidgetReplaces Icon/Label with arbitrary content in the chrome.
SizeSizeThe shared size presets.
OutlineboolBordered while off.
DisabledboolDimmed, unclickable.
ToggleGroup.Options[]ToggleOptionThe choices: Label, Value, Icon, Content. ToggleOpts("a","b") builds label-only lists (the longer name: ToggleProps is this component's per-call options struct).
ToggleGroup.Value() / SetValue(v)stringSingle-select choice; unknown values clear.
ToggleGroup.Values() / SetValues(vs)[]stringMulti-select choices, in Options order; unknown values ignored.
ToggleGroup.MultipleboolIndependent choices instead of radio semantics.
ToggleGroup.Outline / DisabledboolGroup-wide chrome and state.
ToggleGroup.Vertical / Spacingbool / unit.DpStacked axis; gap override (default 2dp).

Every demo on this site is the real Go component compiled to WebAssembly — one gallery app, one bundle, addressed by URL hash.