checkbox

package
v1.0.33-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package checkbox provides a stateful checkbox with an optional label.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checkbox

type Checkbox struct {
	// Contextual gives it a context menu (Context).
	elements.Contextual
	// contains filtered or unexported fields
}

Checkbox is a stateful checkbox with an optional label. Create it once with New and lay it out every frame.

func New

func New(label string, st ...styles.Styles) *Checkbox

New returns a Checkbox. label is optional: pass "" for a bare checkbox with no label. The styles argument is optional: Color is the label color, Background is the checked fill, BorderColor is the unchecked border, BorderWidth and BorderRadius the border, and Width/Height size the box (default 18x18).

func (*Checkbox) CacheSafe

func (c *Checkbox) CacheSafe() bool

CacheSafe reports true: what it draws comes from its own fields, which the cache watches.

func (*Checkbox) Checked

func (c *Checkbox) Checked() bool

Checked reports the current state.

func (*Checkbox) Icon

func (c *Checkbox) Icon(src icon.Source, st ...styles.Styles) *Checkbox

Icon replaces the check mark shown when checked with any icon.Source (a loaded SVG, a registered icon, path data). The styles argument is optional and overrides the icon's Color (default white) and size (defaults to the box size). Icon(nil) restores the built-in check mark.

func (*Checkbox) Layout

func (c *Checkbox) Layout(gtx layout.Context) layout.Dimensions

Layout lays out and updates the checkbox.

func (*Checkbox) OnChange

func (c *Checkbox) OnChange(fn func(checked bool)) *Checkbox

OnChange sets the handler invoked when the state changes. It returns c for chaining.

func (*Checkbox) Outlined

func (c *Checkbox) Outlined(on bool) *Checkbox

Outlined draws a checked box as an outline in the Background colour with a check mark of the same colour, instead of filling it: for outline-only designs. It returns c for chaining.

func (*Checkbox) SetChecked

func (c *Checkbox) SetChecked(v bool)

SetChecked sets the state without invoking OnChange.

func (*Checkbox) Toggle

func (c *Checkbox) Toggle()

Toggle flips the state and invokes OnChange, as a click would.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL