iconbutton

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 7 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

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

Button is a stateful clickable icon-only button. Create it once with New and lay it out every frame; the icon, styles and handler may change at any time.

func New

func New(icon elements.Element, st ...styles.Styles) *Button

New returns a Button laying out icon. The styles argument is optional: Background is the fill, Color the hover/press tint of the transparent variants. The icon carries its own color and size.

func (*Button) Click

func (b *Button) Click()

Click simulates a click programmatically.

func (*Button) Icon

func (b *Button) Icon(icon elements.Element) *Button

Icon replaces the icon. It returns b for chaining.

func (*Button) Label

func (b *Button) Label(label string) *Button

Label sets the accessible name reported to automation (the semantic tree, the MCP server), since the button shows no text. It returns b for chaining.

func (*Button) Layout

func (b *Button) Layout(gtx layout.Context) layout.Dimensions

Layout lays out and updates the button.

func (*Button) OnClick

func (b *Button) OnClick(fn func()) *Button

OnClick sets the handler invoked on every click. It returns b for chaining.

func (*Button) Styles

func (b *Button) Styles(st styles.Styles) *Button

Styles replaces the button styles. It returns b for chaining.

func (*Button) Variant

func (b *Button) Variant(v Variant) *Button

Variant sets the button's visual style (VariantContained, the default, VariantOutlined or VariantGhost). It returns b for chaining.

type Variant

type Variant string

Variant selects the button's visual style.

const (
	// VariantContained fills the button with Background (or black if
	// unset) at all times - the default.
	VariantContained Variant = "contained"
	// VariantOutlined is transparent with a visible border, filling
	// faintly with the border color on hover/press.
	VariantOutlined Variant = "outlined"
	// VariantGhost is fully transparent at rest - only the icon is
	// visible - filling faintly with Color on hover/press.
	VariantGhost Variant = "ghost"
)

Jump to

Keyboard shortcuts

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