Palette

A fixed row of colour swatches.

The smallest palette#

Luau
main:Palette({
    Text = "Trail colour",
    Callback = function(colour)
        trailColour = colour
    end,
})

Without Colors it uses a built-in set of eight.

Preview

My Script

v1.0

Trail colour

Building it up#

Choose the swatches:

Luau
main:Palette({
    Text = "Trail colour",
    Colors = {
        Color3.fromRGB(232, 93, 93),
        Color3.fromRGB(90, 209, 122),
        Color3.fromRGB(74, 168, 240),
    },
    Default = 2, -- 1-based index into Colors
    Callback = setTrailColour,
})

Every option#

OptionTypeDefaultWhat it does
TextreqstringThe label.
Callbackfunction(Color3, number)Called with the chosen colour and its 1-based index.
ColorsColor3[]The swatches to offer. Colours is accepted too. Entries that are not Color3 values are dropped.
Defaultnumber | Color3The starting swatch, as a 1-based index or as one of the colours in Colors. Defaults to 1.
DescriptionstringA quieter second line.
IconstringAn icon shown before the label.
Savestring | booleanPersist the choice under this key. true derives one from the section and label.
TooltipstringShown while the pointer is over the control.
DisabledbooleanfalseRefuses input and dims the control.
DisabledReasonstringShown as a tooltip while it is disabled.

Colors or Colours

Both spellings work. The library reads Colors first and falls back to Colours.

Methods#

MethodReturnsWhat it does
Get()Color3, numberThe selected colour and its index
Set(value)true, or false, reasonSelects a swatch and fires Callback

Set takes a 1-based index, or a Color3 that is one of the swatches. A colour that is not in Colors, and an index past the end of the list, both return false and a reason.

Luau
local trail = main:Palette({ Text = "Trail colour", Colors = swatches })
 
local colour, index = trail:Get()
trail:Set(3)

Palette or ColorPicker?#

Use a palette when the choices are a short fixed list, such as team colours or rarity tiers. Picking one is a single click, and the user can only land on a colour you supplied.

Use a ColorPicker when the user needs any colour in the spectrum. It opens a panel and takes a drag to set.

Both take Save. A palette stores the index it is showing; a colour picker stores the red, green and blue channels.