Icon

按需使用 Lucide 矢量图标。

实时预览

正在加载预览…

参数配置

全部字段 5

IconOptions

Styles · 0

Go 代码

Go
// Inside a view; c is *ui.Context, t is nui.Theme.
nui.Icon(c.Key("icon"), t, lucide.Check(), nui.IconOptions{Size: nui.Set(float32(40)), Label: "Example icon"}).AlignSelf(ui.Start)

使用说明

选择 Lucide 图标并调整像素尺寸,预览直接绘制 SVG。完整示例展示图标包的按需导入;仅图标控件应提供能说明用途的 Label。

API 参考

func Icon(c *ui.Context, t Theme, svg *ui.SVG, opts IconOptions) ui.Element

IconOptions

源码
type IconOptions struct {
	Size  Optional[float32]
	Color Optional[ui.Color]
	Label string
	Decoration
}
字段类型说明
SizeOptional[float32]

Go 零值: unset

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

ColorOptional[ui.Color]

Go 零值: unset

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

Labelstring

Go 零值: ""

控件标签或可访问名称。

UIStyles

Go 零值: zero value

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

Stylefunc(Slot, ui.Element)

Go 零值: nil

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