LogoObsidian

Color Picker

Color pickers let users choose colors (optionally with transparency) from a toggle or label reference.

Playground

This is a toggle
Values must be between 0 and 1.
Allow transparency selection

Usage

You can create a Color Picker by calling the AddColorPicker method on a toggle or label reference.

Arguments

local Toggle = Groupbox:AddToggle("MyToggle", {
    Text = "This is a toggle",
    Default = true,
})
 
local ColorPicker = Toggle:AddColorPicker("ColorPicker1", {
    Default = Color3.new(1, 0, 0),
    Title = "Some color",
})
Arg IdxArgument DescriptionTypeDefault
1Index/ID of the color pickerstringnil
2Color picker configuration tabletablenil

Configuration Table

Prop

Type

Methods

You can use the following methods to interact with the color picker:

SetValue

Sets the color using HSV components.

ColorPicker:SetValue(hsv, transparency)
Arg IdxArgument DescriptionTypeDefault
1HSV table (e.g. {H = 0, S = 1, V = 1})tablenil
2Transparency between 0 and 1numbernil

SetValueRGB

Sets the color using an RGB Color3 value.

ColorPicker:SetValueRGB(color, transparency)
Arg IdxArgument DescriptionTypeDefault
1RGB color (Color3)Color3nil
2Transparency between 0 and 1numbernil

OnChanged

Registers an additional change callback.

ColorPicker:OnChanged(function)
Arg IdxArgument DescriptionTypeDefault
1Callback executed when the color changesfunctionnil

Example

local Options = Library.Options
 
local Toggle = Groupbox:AddToggle("MyToggle", {
    Text = "This is a toggle",
    Default = true,
})
 
local ColorPicker = Toggle:AddColorPicker("ColorPicker1", {
    Default = Color3.new(1, 0, 0),
    Title = "Some color",
    Transparency = 0,
})
 
Options.ColorPicker1:OnChanged(function()
    print("Color changed!", Options.ColorPicker1.Value)
    if Options.ColorPicker1.Transparency then
        print("Transparency changed!", Options.ColorPicker1.Transparency)
    end
end)
 
Options.ColorPicker1:SetValueRGB(Color3.fromRGB(0, 255, 140))

Color pickers can also be attached to labels via AddLabel(...):AddColorPicker(...) for static UI configuration.

On this page