Banner

在页面内展示可关闭的通知条。

实时预览

正在加载预览…

参数配置

全部字段 9

BannerOptions

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.Banner(c.Key("banner"), t, &s.Open, nui.BannerOptions{Title: "An update is available", Description: "Review the new release notes.", Color: nui.ColorDefault})
nui.Button(c.Key("show"), t, "Show banner", nui.ButtonOptions{Variant: nui.Outline}).OnClick(func() { s.Open = true })

使用说明

关闭通知条,再用 Show banner 重新显示。Banner 的可见状态由外部布尔值控制,适合在当前内容区域展示可关闭的消息。

API 参考

Banner

源码
func Banner(c *ui.Context, t Theme, open *bool, o BannerOptions) ui.Element

BannerOptions

源码
type BannerOptions struct {
	Title, Description, CloseLabel string
	Color                          Color
	Icon                           *ui.SVG
	Actions                        func(*ui.Context, Theme)
	OnClose                        func()
	Decoration
}
字段类型说明
Titlestring

Go 零值: ""

标题文字。

Descriptionstring

Go 零值: ""

补充说明文字。

CloseLabelstring

Go 零值: ""

关闭操作的可访问名称。

ColorColor

Go 零值: ColorDefault

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

Icon*ui.SVG

Go 零值: nil

组件使用的 SVG 图标。

Actionsfunc(*ui.Context, Theme)

Go 零值: nil

附加操作或操作区域构建函数。

OnClosefunc()

Go 零值: nil

关闭组件时通知应用的回调。

UIStyles

Go 零值: zero value

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

Stylefunc(Slot, ui.Element)

Go 零值: nil

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