Documentation
¶
Overview ¶
Package button provides a stateful clickable button component built on the stateless elements.
Index ¶
- type Button
- func (b *Button) CacheSafe() bool
- func (b *Button) Click()
- func (b *Button) Disabled(v bool) *Button
- func (b *Button) Focus()
- func (b *Button) Focused() bool
- func (b *Button) Icon(el elements.Element) *Button
- func (b *Button) IsDisabled() bool
- func (b *Button) IsLoading() bool
- func (b *Button) Label(label string) *Button
- func (b *Button) Layout(gtx layout.Context) layout.Dimensions
- func (b *Button) Loading(v bool) *Button
- func (b *Button) OnClick(fn func()) *Button
- func (b *Button) Styles(st styles.Styles) *Button
- func (b *Button) TrailingIcon(el elements.Element) *Button
- func (b *Button) Variant(v Variant) *Button
- type Variant
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 button. Create it once with New and lay it out every frame; label, styles and handler may change at any time.
func (*Button) CacheSafe ¶
CacheSafe reports whether the button can cache its output: its icons, if any, must be CacheSafe too.
func (*Button) Click ¶
func (b *Button) Click()
Click simulates a click programmatically. It does nothing while the button is disabled or loading.
func (*Button) Disabled ¶
Disabled dims the button and ignores input: no clicks, no hover, default cursor. It returns b for chaining.
func (*Button) Focus ¶
func (b *Button) Focus()
Focus gives the button keyboard focus on the next frame.
func (*Button) Icon ¶
Icon sets an element shown before the label, typically an icon. Icons that set no Color of their own follow the label color. It returns b for chaining; Icon(nil) removes it.
func (*Button) IsDisabled ¶
IsDisabled reports whether the button is disabled.
func (*Button) Layout ¶
func (b *Button) Layout(gtx layout.Context) layout.Dimensions
Layout lays out and updates the button. It replays the output recorded last time until its label, styles, state, hover or press, constraints or direction change.
func (*Button) Loading ¶
Loading shows a spinner in place of the icon and ignores clicks while v is true - for actions in progress. It returns b for chaining.
func (*Button) OnClick ¶
OnClick sets the handler invoked on every click. It returns b for chaining.
func (*Button) TrailingIcon ¶
TrailingIcon sets an element shown after the label - a chevron, an external-link mark. It follows the label color like Icon. 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, and today's only look before // Variant existed. 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 label is // visible - filling faintly with Background on hover/press. VariantGhost Variant = "ghost" )