chip

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: 6 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 chip provides chips: small rounded labels for filters, tags and choices, optionally selectable and removable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chip

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

Chip is a rounded label with an optional icon, a selected state and a remove button. Without OnClick or OnRemove it's a plain element that can be built every frame; with them, create it once (or with Keyed), since it then holds press state.

func New

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

New returns a chip. The styles argument is optional: Background (default a faint tint of the text), Color (default theme.text), BorderColor, FontSize. They style the unselected chip; a selected chip keeps its theme.primary fill and theme.onprimary text unless SelectedStyles sets others.

func (*Chip) Click

func (c *Chip) Click()

Click runs the click handler, as a tap would.

func (*Chip) Icon

func (c *Chip) Icon(el elements.Element) *Chip

Icon shows el before the label. It returns c for chaining.

func (*Chip) IsSelected

func (c *Chip) IsSelected() bool

IsSelected reports the selected state.

func (*Chip) Layout

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

Layout lays out the chip.

func (*Chip) OnClick

func (c *Chip) OnClick(fn func()) *Chip

OnClick makes the chip tappable. It returns c for chaining.

func (*Chip) OnRemove

func (c *Chip) OnRemove(fn func()) *Chip

OnRemove adds a remove (x) button after the label. It returns c for chaining.

func (*Chip) Selected

func (c *Chip) Selected(on bool) *Chip

Selected sets the selected state, drawn filled. It returns c for chaining.

func (*Chip) SelectedStyles

func (c *Chip) SelectedStyles(st styles.Styles) *Chip

SelectedStyles sets the styles merged over st when the chip is selected (default Background theme.primary, Color theme.onprimary, BorderColor theme.primary). It returns c for chaining.

Jump to

Keyboard shortcuts

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