Skip to content

Badge

Badge preview

Badge is a small pill-shaped label for counts, statuses, or tags.

Constructor func NewBadge(text string) *Badge

Usage

badge := components.NewBadge("42").
SetVariant(components.BadgeSuccess).
SetIcon("").
SetPill(true)
fmt.Println(badge != nil)

Methods

Method Signature Description
GetFieldHeight func (b *Badge) GetFieldHeight() int GetFieldHeight returns preferred height
GetText func (b *Badge) GetText() string GetText returns the badge text
SetIcon func (b *Badge) SetIcon(icon string) *Badge SetIcon sets an icon prefix
SetPill func (b *Badge) SetPill(pill bool) *Badge SetPill enables/disables pill (rounded) style
SetText func (b *Badge) SetText(text string) *Badge SetText sets the badge text
SetVariant func (b *Badge) SetVariant(v BadgeVariant) *Badge SetVariant sets the badge color variant
Width func (b *Badge) Width() int Width returns the badge's preferred width

Types

type BadgeVariant BadgeVariant controls the color scheme of a Badge: Default (neutral gray), Primary (accent), Success (green), Warning (yellow), Error (red), Info (blue).
ConstantDescription
BadgeDefault
BadgePrimary
BadgeSuccess
BadgeWarning
BadgeError
BadgeInfo