Empty
解释没有内容时的状态和下一步。
实时预览
正在加载预览…
参数配置
全部字段 11
EmptyOptions
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.ElementEmptyOptions
源码type EmptyOptions struct {
Title, Description string
Icon *ui.SVG
Size Size
Variant Variant
Loading bool
LoadingIcon *ui.SVG
Actions, Footer func()
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Title | stringGo 零值: | 标题文字。 |
Description | stringGo 零值: | 补充说明文字。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
Size | SizeGo 零值: | 组件尺寸;默认值继承主题或组件尺寸。 |
Variant | VariantGo 零值: | 组件外观样式,支持范围取决于组件。 |
Loading | boolGo 零值: | 显示加载状态;是否阻止操作由组件决定。 |
LoadingIcon | *ui.SVGGo 零值: | 覆盖默认加载图标。 |
Actions | func()Go 零值: | 附加操作或操作区域构建函数。 |
Footer | func()Go 零值: | 同步构建底部区域。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |