ColorPicker
通过色板和数值选择颜色。
实时预览
正在加载预览…
参数配置
全部字段 5
ColorPickerOptions
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.ElementColorPickerOptions
源码type ColorPickerOptions struct {
Label string
Disabled bool
OnChange func(ui.Color)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Label | stringGo 零值: | 控件标签或可访问名称。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
OnChange | func(ui.Color)Go 零值: | 值发生变化时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |