Radio
Chooses one value from a small set, all visible at once.
Loading the live example…
import (
"github.com/egoist/mygo/ui"
"github.com/oneo-me/onevra/source/components"
)
type shipping struct {
method string
}
func (s *shipping) View(c *ui.Context) {
ui.Column(c).Gap(12).Children(func() {
components.Radio(c, &s.method, "standard", "Standard, 3–5 days")
components.Radio(c, &s.method, "express", "Express, next day")
components.Radio(c, &s.method, "pickup", "Pick up in store")
})
}components.Radio is generic: each button writes its value into the shared *T when chosen. For longer lists, use a select.
API
Radio
func Radio[T comparable](c *ui.Context, selected *T, value T, label string) ui.ElementRadio creates a radio button that selects value into *selected, with a label. The label is also the accessible name.
pkg.go.dev