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

RadioGroup

The exclusive choice: labeled circles, exactly one selected.

Options carry their own Description and Disabled flag; clicks are processed at the top of Layout, so the click's own frame renders the new selection.

Like every choice component, the selection is a VALUE: the cursor is unexported, Value()/SetValue() read and write it, the zero value picks the first option, and an unknown value clears rather than falling back to option 0 — see Select for the full contract.

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 radio-group

Usage

Go
density := lotusui.RadioGroup{
	Options: lotusui.RadioOpts("Default", "Comfortable", "Compact"),
}
density.SetValue(stored) // an unknown value clears, never picks option 0

density.Layout(th, gtx)
stored = density.Value()

Disabled option

Go
plans := lotusui.RadioGroup{Options: []lotusui.RadioOption{
	{Label: "Starter", Value: "starter"},
	{Label: "Pro (contact sales)", Value: "pro", Disabled: true},
	{Label: "Enterprise", Value: "enterprise"},
}}

Description

Each option's Description renders muted under its label.

Go
density := lotusui.RadioGroup{Options: []lotusui.RadioOption{
	{Label: "Default", Value: "default", Description: "Standard spacing for most use cases."},
	{Label: "Comfortable", Value: "comfortable", Description: "More space between elements."},
	{Label: "Compact", Value: "compact", Description: "Dense layout for scanning lots of data."},
}}

Invalid

Invalid renders danger rings; pair it with a Field error.

Go
prefs := lotusui.RadioGroup{Invalid: true}

API

OptionTypeDescription
Options[]RadioOptionThe choices: Label, Value, Description (muted sub-label) and Disabled. RadioOpts("a","b") builds label-only lists.
Value() / SetValue(v)stringThe chosen option's value; SetValue with an unknown value clears.
Clear() / Chosen()methodDrop the choice; whether anything is chosen.
SizeSizeThe shared size presets scale the circles.
InvalidboolDanger chrome on the circles.

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