Tabs

在相关内容面板之间切换。

实时预览

正在加载预览…

参数配置

全部字段 11

TabsItems

列表项 · 2
TabItem
TabItem

TabsOptions

Styles · 0

Go 代码

Go
// Inside a view; c is *ui.Context, t is nui.Theme.
// Keep s (example state) outside the view. See the complete example.
nui.Tabs(c.Key("tabs"), t, &s.Value, []nui.TabItem{{ID: "overview", Label: "Overview", Content: func(c *ui.Context, t nui.Theme) { ui.Text(c, "Project overview") }}, {ID: "settings", Label: "Settings", Content: func(c *ui.Context, t nui.Theme) { ui.Text(c, "Project settings") }}}, nui.TabsOptions{Label: "Project tabs", Color: nui.ColorDefault, Size: nui.SizeDefault, Vertical: false, Underline: false})

使用说明

切换 Overview 与 Settings 面板,并比较下划线与纵向排列。选择状态记录项目 ID;面板内容由各自的同步回调构建。

API 参考

func Tabs(c *ui.Context, t Theme, value *string, items []TabItem, o TabsOptions) ui.Element

TabsOptions

源码
type TabsOptions struct {
	Label                            string
	Color                            Color
	Size                             Size
	Underline, Vertical, KeepMounted bool
	ActivationMode                   ActivationMode
	OnChange                         func(string)
	Decoration
}
字段类型说明
Labelstring

Go 零值: ""

控件标签或可访问名称。

ColorColor

Go 零值: ColorDefault

语义颜色;默认值继承主题或组件配色。

SizeSize

Go 零值: SizeDefault

组件尺寸;默认值继承主题或组件尺寸。

Underlinebool

Go 零值: false

使用下划线形式标示当前标签页。

Verticalbool

Go 零值: false

启用纵向排列。

KeepMountedbool

Go 零值: false

隐藏时保留内容及其控件状态。

ActivationModeActivationMode

Go 零值: zero value

键盘移动焦点时自动或手动激活标签页。

OnChangefunc(string)

Go 零值: nil

值发生变化时通知应用的回调。

UIStyles

Go 零值: zero value

以部件名称为键覆盖外观和间距。

Stylefunc(Slot, ui.Element)

Go 零值: nil

同步配置当前构建的部件;不要保留 Element。