button

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateButton

func ValidateButton(b *Button) error

ValidateButton validates that a button has all required fields

Types

type Button

type Button struct {

	// Configuration
	Text     string
	Variant  theme.Variant
	Size     theme.Size
	Icon     *widget.Icon
	Disabled bool
	Classes  string
	OnClick  func()
	// contains filtered or unexported fields
}

Button represents a shadcn/ui button component

func New

func New(config Config) *Button

New creates a new button with the given configuration

func NewButton

func NewButton(options ...ButtonOption) *Button

NewButton creates a new Button with the given options

func (*Button) Clicked

func (b *Button) Clicked(gtx layout.Context) bool

Clicked returns true if the button was clicked

func (*Button) Layout

func (b *Button) Layout(gtx layout.Context, th *theme.Theme) layout.Dimensions

Layout renders the button

func (*Button) SafeLayout

func (b *Button) SafeLayout(gtx layout.Context, th *theme.Theme) (layout.Dimensions, error)

SafeLayout is a wrapper around Layout that validates the button first

func (*Button) SetDisabled

func (b *Button) SetDisabled(disabled bool)

SetDisabled sets the disabled state of the button

func (*Button) SetOnClick

func (b *Button) SetOnClick(onClick func())

SetOnClick sets the click handler

func (*Button) SetText

func (b *Button) SetText(text string)

SetText sets the button text

func (*Button) SetVariant

func (b *Button) SetVariant(variant theme.Variant)

SetVariant sets the button variant

func (*Button) Update

func (b *Button) Update(gtx layout.Context) theme.ComponentState

type ButtonOption

type ButtonOption func(*Button)

ButtonOption is a functional option for configuring Button components

func WithClasses

func WithClasses(classes string) ButtonOption

WithClasses sets additional CSS-like classes

func WithDisabled

func WithDisabled(disabled bool) ButtonOption

WithDisabled sets the disabled state

func WithIcon

func WithIcon(icon *widget.Icon) ButtonOption

WithIcon sets the button icon

func WithOnClick

func WithOnClick(onClick func()) ButtonOption

WithOnClick sets the click handler

func WithSize

func WithSize(size theme.Size) ButtonOption

WithSize sets the button size

func WithText

func WithText(text string) ButtonOption

WithText sets the button text

func WithVariant

func WithVariant(variant theme.Variant) ButtonOption

WithVariant sets the button variant

type ButtonState

type ButtonState struct {
	// contains filtered or unexported fields
}

func (*ButtonState) IsActive

func (bs *ButtonState) IsActive() bool

func (*ButtonState) IsDisabled

func (bs *ButtonState) IsDisabled() bool

func (*ButtonState) IsHovered

func (bs *ButtonState) IsHovered() bool

func (*ButtonState) IsPressed

func (bs *ButtonState) IsPressed() bool

type Config

type Config struct {
	Text     string
	Variant  theme.Variant
	Size     theme.Size
	Icon     *widget.Icon
	Disabled bool
	Classes  string
	OnClick  func()
}

Config represents button configuration

Jump to

Keyboard shortcuts

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