InputRating
用星级选择评分。
实时预览
正在加载预览…
参数配置
全部字段 14
InputRatingOptions
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.InputRating(c.Key("rating"), t, &s.Value, nui.InputRatingOptions{Label: "Rating", Max: 5, Color: nui.ColorDefault, Size: nui.SizeDefault, Disabled: false, ReadOnly: false, Orientation: nui.Horizontal, Clearable: false})
ui.Textf(c, "Rating: %d", s.Value)使用说明
选择星级并观察下方数值,试试只读、清空和方向设置。Max 决定评分范围,应用保存整数值并决定是否提交评分。
API 参考
InputRating
源码func InputRating(c *ui.Context, t Theme, value *int, o InputRatingOptions) ui.ElementInputRatingOptions
源码type InputRatingOptions struct {
Label string
Max int
Disabled, ReadOnly bool
Color Color
Size Size
Orientation Orientation
Clearable bool
Hoverable Optional[bool]
Icon, EmptyIcon *ui.SVG
OnChange func(int)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Label | stringGo 零值: | 控件标签或可访问名称。 |
Max | intGo 零值: | 上界或数量上限,具体含义依组件而定。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
ReadOnly | boolGo 零值: | 允许读取和选择内容,但禁止编辑。 |
Color | ColorGo 零值: | 语义颜色;默认值继承主题或组件配色。 |
Size | SizeGo 零值: | 组件尺寸;默认值继承主题或组件尺寸。 |
Orientation | OrientationGo 零值: | 水平或垂直方向;未设置时使用组件默认方向。 |
Clearable | boolGo 零值: | 显示清空操作或允许清除当前值。 |
Hoverable | Optional[bool]Go 零值: | 悬停时显示临时评分预览。 |
Icon | *ui.SVGGo 零值: | 组件使用的 SVG 图标。 |
EmptyIcon | *ui.SVGGo 零值: | 未填充评分项的图标。 |
OnChange | func(int)Go 零值: | 值发生变化时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |