Button
可访问的按压目标,可自行设置样式并组合文本或其他内容。
正在加载交互演示…
func ButtonExample(save func()) *ui.Element {
return ui.Button().Child("Save changes").
Height(40).
PaddingLeft(16).
PaddingRight(16).
BackgroundColor("#2563eb").
TextColor("white").
BorderRadius(8).
Hover(func(s ui.StyleBuilder) ui.StyleBuilder { return s.BackgroundColor("#3b82f6") }).
OnClick(save)
}#导入
从 github.com/egoist/quickgui/go/ui 导入 ui。
import (
"github.com/egoist/quickgui/go/ui"
)#用法
func ButtonExample(save func()) *ui.Element {
return ui.Button().Child("Save changes").
Height(40).
PaddingLeft(16).
PaddingRight(16).
BackgroundColor("#2563eb").
TextColor("white").
BorderRadius(8).
Hover(func(s ui.StyleBuilder) ui.StyleBuilder { return s.BackgroundColor("#3b82f6") }).
OnClick(save)
}#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
Button
查看源码ui.Button() *ElementButton constructs an empty button. Add content with Child or Children.
ChildChild(child any) *Element—
Child appends content and returns this element. Content can be an element, native node, scalar, accessor, or node-returning construction callback.
Child(child any) *Element查看源码ChildrenChildren(children ...any) *Element—
Children appends multiple children in order without replacing existing content. It also accepts []any, []*Element, and []*native.Node slices as arguments. Read the retained child nodes through element.Node.Children.
Children(children ...any) *Element查看源码StyleStyle(style StyleBuilder) *Element—
Style merges a reusable style. Scalar accessors retain independent native bindings.
Style(style StyleBuilder) *Element查看源码OnClickOnClick(handler func()) *Element—
RefRef(handler func(*native.Node)) *Element—
Ref exposes the native handle once at this point in the declaration chain.
Ref(handler func(*native.Node)) *Element查看源码PaddingPadding(value any) *Element—
BackgroundColorBackgroundColor(value any) *Element—
OnKeyDownOnKeyDown(value func(*native.Event)) *Element—
OnKeyDown configures the corresponding node property.
OnKeyDown(value func(*native.Event)) *Element查看源码OnFocusOnFocus(value func(*native.Event)) *Element—
OnBlurOnBlur(value func(*native.Event)) *Element—
DisabledDisabled(value any) *Element—
AriaLabelAriaLabel(value any) *Element—
FocusOnPointerFocusOnPointer(value any) *Element—
FocusableWhenDisabledFocusableWhenDisabled(value any) *Element—
FocusableWhenDisabled configures the corresponding node property.
FocusableWhenDisabled(value any) *Element查看源码