InputRating

用星级选择评分。

实时预览

正在加载预览…

参数配置

全部字段 14

InputRatingOptions

Styles · 0

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.Element

InputRatingOptions

源码
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
}
字段类型说明
Labelstring

Go 零值: ""

控件标签或可访问名称。

Maxint

Go 零值: 0

上界或数量上限,具体含义依组件而定。

Disabledbool

Go 零值: false

禁用组件及其交互。

ReadOnlybool

Go 零值: false

允许读取和选择内容,但禁止编辑。

ColorColor

Go 零值: ColorDefault

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

SizeSize

Go 零值: SizeDefault

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

OrientationOrientation

Go 零值: zero value

水平或垂直方向;未设置时使用组件默认方向。

Clearablebool

Go 零值: false

显示清空操作或允许清除当前值。

HoverableOptional[bool]

Go 零值: unset

悬停时显示临时评分预览。

Icon*ui.SVG

Go 零值: nil

组件使用的 SVG 图标。

EmptyIcon*ui.SVG

Go 零值: nil

未填充评分项的图标。

OnChangefunc(int)

Go 零值: nil

值发生变化时通知应用的回调。

UIStyles

Go 零值: zero value

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

Stylefunc(Slot, ui.Element)

Go 零值: nil

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