Empty

解释没有内容时的状态和下一步。

实时预览

正在加载预览…

参数配置

全部字段 11

EmptyOptions

Styles · 0

Go 代码

Go
// Inside a view; c is *ui.Context, t is nui.Theme.
nui.Empty(c.Key("empty"), t, nui.EmptyOptions{Title: "No projects yet", Description: "Create a project to get started.", Icon: lucide.Folder(), Size: nui.SizeDefault, Variant: nui.VariantDefault, Loading: false, Actions: func() { nui.Button(c.Key("create"), t, "Create project", nui.ButtonOptions{}) }})

使用说明

修改标题、尺寸与加载状态,比较空内容的呈现方式。示例的 Create project 按钮是操作区的组合示范,应用可在这里绑定创建流程。

API 参考

Empty

源码
func Empty(c *ui.Context, t Theme, opts EmptyOptions) ui.Element

EmptyOptions

源码
type EmptyOptions struct {
	Title, Description string
	Icon               *ui.SVG
	Size               Size
	Variant            Variant
	Loading            bool
	LoadingIcon        *ui.SVG
	Actions, Footer    func()
	Decoration
}
字段类型说明
Titlestring

Go 零值: ""

标题文字。

Descriptionstring

Go 零值: ""

补充说明文字。

Icon*ui.SVG

Go 零值: nil

组件使用的 SVG 图标。

SizeSize

Go 零值: SizeDefault

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

VariantVariant

Go 零值: VariantDefault

组件外观样式,支持范围取决于组件。

Loadingbool

Go 零值: false

显示加载状态;是否阻止操作由组件决定。

LoadingIcon*ui.SVG

Go 零值: nil

覆盖默认加载图标。

Actionsfunc()

Go 零值: nil

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

Footerfunc()

Go 零值: nil

同步构建底部区域。

UIStyles

Go 零值: zero value

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

Stylefunc(Slot, ui.Element)

Go 零值: nil

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