Checkbox
Turns an option on or off, for choices that apply when a form is submitted.
Loading the live example…
import (
"github.com/egoist/mygo/ui"
"github.com/oneo-me/onevra/source/components"
)
type signup struct {
terms, newsletter bool
}
func (s *signup) View(c *ui.Context) {
ui.Column(c).Gap(12).Children(func() {
components.Checkbox(c, &s.terms, "I accept the terms")
components.Checkbox(c, &s.newsletter, "Send me product news")
components.Button(c, "Create account", components.ButtonPrimary).Disabled(!s.terms)
})
}components.Checkbox toggles a *bool, and its label is also its accessible name. For a setting that applies at once, use a switch.
API
Checkbox
func Checkbox(c *ui.Context, checked *bool, label string) ui.ElementCheckbox creates a check box toggling *checked, with a label. The label is also the accessible name.
pkg.go.dev