Alert
突出重要信息和状态反馈。
实时预览
正在加载预览…
参数配置
全部字段 10
AlertOptions
Go 代码
Go
// Inside a view; c is *ui.Context, t is nui.Theme.
nui.Alert(c.Key("alert"), t, nui.AlertOptions{Title: "Changes saved", Description: "Your changes are ready to review.", Color: nui.ColorDefault, Variant: nui.VariantDefault, Icon: lucide.Info(), Orientation: nui.Set(nui.Horizontal)})使用说明
调整标题、语义颜色、样式与方向,观察图标和说明的排列。Alert 适合在内容区域持续解释状态;示例使用固定说明文字。
API 参考
Alert
源码func Alert(c *ui.Context, t Theme, opts AlertOptions) ui.ElementAlertOptions
源码type AlertOptions struct {
Title, Description string
Color Color
Variant Variant
Icon *ui.SVG
Actions func()
Orientation Optional[Orientation] // Defaults to Vertical.
OnClose func()
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Title | stringGo 零值: | 标题文字。 |
Description | stringGo 零值: | 补充说明文字。 |
Color | ColorGo 零值: | 语义颜色;默认值继承主题或组件配色。 |
Variant | VariantGo 零值: | 组件外观样式,支持范围取决于组件。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
Actions | func()Go 零值: | 附加操作或操作区域构建函数。 |
Orientation | Optional[Orientation]Go 零值: | 水平或垂直方向;未设置时使用组件默认方向。 |
OnClose | func()Go 零值: | 关闭组件时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |