ColorPicker

通过色板和数值选择颜色。

实时预览

正在加载预览…

参数配置

全部字段 5

ColorPickerOptions

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.ColorPicker(c.Key("color"), t, &s.Value, &s.Picker, nui.ColorPickerOptions{Label: "Accent color", Disabled: false})

使用说明

拖动取色区域或编辑颜色数值,观察当前选择。ColorPickerState 保存交互状态;这里修改的是示例选色,不会改变整个文档站的主题。

API 参考

ColorPicker

源码
func ColorPicker(c *ui.Context, t Theme, value *ui.Color, s *ColorPickerState, o ColorPickerOptions) ui.Element

ColorPickerOptions

源码
type ColorPickerOptions struct {
	Label    string
	Disabled bool
	OnChange func(ui.Color)
	Decoration
}
字段类型说明
Labelstring

Go 零值: ""

控件标签或可访问名称。

Disabledbool

Go 零值: false

禁用组件及其交互。

OnChangefunc(ui.Color)

Go 零值: nil

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

UIStyles

Go 零值: zero value

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

Stylefunc(Slot, ui.Element)

Go 零值: nil

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