类型 Button

API 文档由 Go 源码生成,内容为英文。

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

Button is one allocation-free in-flight button declaration.

构造函数

BeginButton#

func BeginButton(canvas *ui.Canvas, theme ui.Theme, id ui.ID, bounds ui.Rect) Button

BeginButton starts a button declaration. Hit ID zero paints a static preview without adding an interaction region.

方法

BoundsHeight#

func (button Button) BoundsHeight() float32

BoundsHeight exposes the height the selected size paints at.

BoundsWidth#

func (button Button) BoundsWidth() float32

BoundsWidth exposes the fitted width for callers laying out neighbors.

CenterIn#

func (button Button) CenterIn(area ui.Rect) Button

CenterIn centers the button's current bounds within area. Call it after SizeToFit when an empty state or dialog action needs a centered control.

Default#

func (button Button) Default(label string) ButtonResult

Default paints the primary official default variant.

Destructive#

func (button Button) Destructive(label string) ButtonResult

Destructive paints the official destructive variant.

DestructiveOutline#

func (button Button) DestructiveOutline(label string) ButtonResult

DestructiveOutline paints the bordered, danger-labelled variant.

Disabled#

func (button Button) Disabled() Button

Disabled paints the official 50% opacity state and exposes disabled typed semantics when the declaration has a nonzero ID.

Ghost#

func (button Button) Ghost(label string) ButtonResult

Ghost paints the official borderless variant.

Icon#

func (button Button) Icon() Button

Icon selects the square default icon size.

IconLarge#

func (button Button) IconLarge() Button

IconLarge selects the square 40px icon size at default density.

IconSmall#

func (button Button) IconSmall() Button

IconSmall selects the square 32px icon size at default density.

IconXSmall#

func (button Button) IconXSmall() Button

IconXSmall selects the square 24px icon size at default density.

Invalid#

func (button Button) Invalid() Button

Invalid applies the official destructive validation ring.

Large#

func (button Button) Large() Button

Large selects the 40px size at default density.

Outline#

func (button Button) Outline(label string) ButtonResult

Outline paints the official bordered variant.

Secondary#

func (button Button) Secondary(label string) ButtonResult

Secondary paints the official secondary variant.

Size#

func (button Button) Size(size ButtonSize) Button

Size selects an official size variant.

SizeToFit#

func (button Button) SizeToFit(label string) Button

SizeToFit widens the button to its label plus the selected size padding.

Small#

func (button Button) Small() Button

Small selects the 32px size at default density.

WithState#

func (button Button) WithState(state ButtonState) Button

WithState pins a visual state, overriding canvas-derived interaction state.

XSmall#

func (button Button) XSmall() Button

XSmall selects the 24px compact size at default density.