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.ToggleOpts{Icon: lotusui.IconTextBold})
if bold.On { /* … */ }

ToggleGroup — single

Go
var format = lotusui.ToggleGroup{Sel: 0}
format.Layout(th, gtx, lotusui.SizeMD,
	lotusui.ToggleGroupItem{Icon: lotusui.IconTextBold},
	lotusui.ToggleGroupItem{Icon: lotusui.IconTextItalic},
	lotusui.ToggleGroupItem{Icon: lotusui.IconTextUnderline},
)

ToggleGroup — multiple

Go
var marks = lotusui.ToggleGroup{Multiple: true}

Sizes

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

Disabled

Go
t.Layout(th, gtx, lotusui.ToggleOpts{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.ToggleGroupItem{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.Sel / Multiple / Onint / bool / []boolSingle-select index, or independent bools.
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.