Skip to content

Chip

Chip preview

Chip is a labeled tag with optional remove button and click handler. Set removable=true via SetRemovable and wire SetOnRemove to handle dismissal.

Constructor func NewChip(text string) *Chip

Usage

chip := components.NewChip("go").
SetRemovable(true)
fmt.Println(chip != nil)

Methods

Method Signature Description
GetFieldHeight func (c *Chip) GetFieldHeight() int GetFieldHeight returns preferred height
GetText func (c *Chip) GetText() string GetText returns the chip text
IsSelected func (c *Chip) IsSelected() bool IsSelected returns whether the chip is selected
SetDisabled func (c *Chip) SetDisabled(disabled bool) *Chip SetDisabled sets the disabled state
SetIcon func (c *Chip) SetIcon(icon string) *Chip SetIcon sets the chip icon
SetOnClick func (c *Chip) SetOnClick(fn func()) *Chip SetOnClick sets the click callback
SetOnRemove func (c *Chip) SetOnRemove(fn func()) *Chip SetOnRemove sets the remove callback
SetRemovable func (c *Chip) SetRemovable(removable bool) *Chip SetRemovable enables/disables the remove button
SetSelected func (c *Chip) SetSelected(selected bool) *Chip SetSelected sets the selected state
SetText func (c *Chip) SetText(text string) *Chip SetText sets the chip text
Width func (c *Chip) Width() int Width returns the chip's preferred width