Complete reference for all option types in the Loolib Configuration system.
- Overview
- Type Categories
- Container Type: group
- Value Types
- Action Type: execute
- Display Types
- Media Types
- Common Properties
- Property Value Types
- Type Validation
- Constants
The ConfigTypes module defines the schema for all option types supported by the Loolib Configuration system. It provides:
- Type specifications with required and optional properties
- Default values for type-specific properties
- Validation functions
- Utility functions for type checking
local Loolib = LibStub("Loolib")
local ConfigTypes = Loolib:GetModule("ConfigTypes")
-- Get all types
local types = ConfigTypes:GetAllTypes()
-- Check if type is container
local isContainer = ConfigTypes:IsContainer("group")
-- Validate an option
local valid, error = ConfigTypes:ValidateOption("range", optionDef)Options are organized into four categories:
- group - Contains other options
- toggle - Boolean checkbox
- input - Text input
- range - Numeric slider
- select - Single selection dropdown
- multiselect - Multiple selection checkboxes
- color - Color picker
- keybinding - Key binding capture
- execute - Button that triggers a function
- header - Section divider
- description - Static text
- texture - Texture display/selector
- font - Font selector
A container that holds other options. The root of every options table must be a group.
{
type = "group",
name = "Group Name",
desc = "Group description",
args = {
-- Child options here
},
childGroups = "tree", -- How to display child groups
inline = false, -- Display inline within parent
}| Property | Type | Default | Description |
|---|---|---|---|
args |
table | (required) | Nested options. Keys become option identifiers |
childGroups |
string | "tree" | Display mode: "tree", "tab", or "select" |
inline |
boolean | false | Display inline instead of separate panel |
Displays child groups in a left sidebar tree navigation.
+-------+-------------------+
| Root | Content Area |
| +Gen | |
| +App | Options display |
| +Adv | here |
+-------+-------------------+
Displays child groups as tabs along the top.
+---------------------------+
| [Gen] [App] [Adv] |
+---------------------------+
| Content Area |
| |
| Options display here |
+---------------------------+
Displays child groups as a dropdown selector.
When inline = true, the group displays as a bordered section within its parent:
colors = {
type = "group",
name = "Colors",
inline = true,
args = {
background = { type = "color", name = "Background" },
text = { type = "color", name = "Text" },
},
}Renders as:
+---------------------------+
| Colors |
| +-----------------------+ |
| | Background: [##] | |
| | Text: [##] | |
| +-----------------------+ |
+---------------------------+
-- Root group with tree navigation
local options = {
type = "group",
name = "My Addon",
childGroups = "tree",
args = {
general = {
type = "group",
name = "General",
order = 1,
args = { ... },
},
appearance = {
type = "group",
name = "Appearance",
order = 2,
args = { ... },
},
},
}
-- Tab-based navigation
local options = {
type = "group",
name = "My Addon",
childGroups = "tab",
args = { ... },
}
-- Group with inline sub-groups
local appearanceGroup = {
type = "group",
name = "Appearance",
args = {
colors = {
type = "group",
name = "Colors",
inline = true,
args = { ... },
},
fonts = {
type = "group",
name = "Fonts",
inline = true,
args = { ... },
},
},
}These types store and retrieve configuration values via get and set.
A boolean checkbox for on/off settings.
{
type = "toggle",
name = "Enable Feature",
desc = "Turn this feature on or off",
get = function(info) return db.enabled end,
set = function(info, value) db.enabled = value end,
tristate = false,
}| Property | Type | Default | Description |
|---|---|---|---|
tristate |
boolean | false | Allow nil as third state |
Normal toggle cycles: true -> false -> true
Tristate toggle cycles: true -> nil -> false -> true
The nil state typically represents "use default" or "inherit from parent".
[x] Enable Feature <- Checked (true)
[ ] Enable Feature <- Unchecked (false)
[-] Enable Feature <- Tristate nil
/addon enabled true
/addon enabled false
/addon enabled yes
/addon enabled no
/addon enabled 1
/addon enabled 0
/addon enabled on
/addon enabled off
/addon enabled nil -- Only for tristate
/addon enabled default -- Only for tristate
A text input field for string values.
{
type = "input",
name = "Welcome Message",
desc = "Message displayed on login",
get = function(info) return db.message end,
set = function(info, value) db.message = value end,
multiline = false,
pattern = nil,
usage = nil,
}| Property | Type | Default | Description |
|---|---|---|---|
multiline |
boolean | false | Multi-line text box |
pattern |
string | nil | Lua pattern for validation |
usage |
string | nil | Usage hint shown on error |
-- Single line (default)
{
type = "input",
name = "Character Name",
multiline = false, -- Optional, this is default
}
-- Multi-line (4 lines by default)
{
type = "input",
name = "Notes",
multiline = true,
width = "full",
}The pattern property uses Lua pattern matching:
{
type = "input",
name = "Email",
pattern = "^[%w.]+@[%w.]+%.%w+$",
usage = "Enter a valid email address (e.g., user@example.com)",
}
{
type = "input",
name = "Player Name",
pattern = "^[A-Za-z][A-Za-z0-9]*$",
usage = "Name must start with a letter and contain only letters/numbers",
}Single-line:
+---------------------------+
| [ ] |
+---------------------------+
Multi-line:
+---------------------------+
| [ ] |
| [ ] |
| [ ] |
| [ ] |
+---------------------------+
A slider for numeric values within a range.
{
type = "range",
name = "Volume",
desc = "Set the audio volume",
min = 0,
max = 100,
softMin = 10,
softMax = 90,
step = 1,
bigStep = 10,
isPercent = false,
get = function(info) return db.volume end,
set = function(info, value) db.volume = value end,
}| Property | Type | Required | Default | Description |
|---|---|---|---|---|
min |
number | Yes | - | Minimum allowed value |
max |
number | Yes | - | Maximum allowed value |
softMin |
number | No | nil | Soft minimum (slider limit, input can exceed) |
softMax |
number | No | nil | Soft maximum (slider limit, input can exceed) |
step |
number | No | 0 | Step increment (0 = continuous) |
bigStep |
number | No | nil | Ctrl+click step increment |
isPercent |
boolean | No | false | Display as percentage |
Soft limits constrain the slider but allow manual input to exceed:
{
type = "range",
name = "Font Size",
min = 1, -- Absolute minimum
max = 100, -- Absolute maximum
softMin = 8, -- Slider starts here
softMax = 24, -- Slider ends here
step = 1,
}Users can drag slider between 8-24, but manually type 1-100.
-- Continuous (smooth)
step = 0,
-- Integer steps
step = 1,
-- Decimal steps
step = 0.1,
step = 0.05,
-- Ctrl+click for larger steps
step = 1,
bigStep = 10,When isPercent = true, values 0-1 display as 0%-100%:
{
type = "range",
name = "Opacity",
min = 0,
max = 1,
step = 0.01,
isPercent = true,
get = function() return db.opacity end, -- Returns 0.75
set = function(_, v) db.opacity = v end, -- Receives 0.75
}
-- Displays as "75%"Volume: [====|=========] 35
A dropdown or radio button selection from predefined values.
{
type = "select",
name = "Font",
desc = "Select display font",
values = {
arial = "Arial",
friz = "Friz Quadrata",
morpheus = "Morpheus",
},
sorting = {"arial", "friz", "morpheus"},
style = "dropdown",
get = function(info) return db.font end,
set = function(info, value) db.font = value end,
}| Property | Type | Required | Default | Description |
|---|---|---|---|---|
values |
table/function | Yes | - | {key = "Label"} or function returning table |
style |
string | No | "dropdown" | "dropdown" or "radio" |
sorting |
table/function | No | nil | Custom sort order: {key1, key2, ...} |
Static values:
values = {
low = "Low",
medium = "Medium",
high = "High",
}Dynamic values:
values = function(info)
local items = {}
for _, item in pairs(GetGameItems()) do
items[item.id] = item.name
end
return items
end,By default, values sort alphabetically by key. Use sorting to customize:
values = {
high = "High Priority",
medium = "Medium Priority",
low = "Low Priority",
},
sorting = {"high", "medium", "low"}, -- Explicit orderDynamic sorting:
sorting = function(info)
return {"newest", "popular", "alphabetical"}
end,dropdown (default):
Font: [Arial v]
radio:
Font:
( ) Arial
(*) Friz Quadrata
( ) Morpheus
get = function(info)
return db.selectedKey -- Returns the KEY, not label
end,
set = function(info, value)
db.selectedKey = value -- Receives the KEY
end,Multiple checkbox selection from predefined values.
{
type = "multiselect",
name = "Enabled Modules",
desc = "Select which modules to enable",
values = {
combat = "Combat Tracker",
inventory = "Inventory Manager",
map = "Map Enhancements",
},
tristate = false,
get = function(info, key) return db.modules[key] end,
set = function(info, key, value) db.modules[key] = value end,
}| Property | Type | Required | Default | Description |
|---|---|---|---|---|
values |
table/function | Yes | - | {key = "Label"} or function returning table |
tristate |
boolean | No | false | Allow nil as third state per item |
Important: Unlike other types, multiselect passes key to get/set:
-- Get receives key
get = function(info, key)
return db.modules[key] -- Return boolean for this key
end,
-- Set receives key and value
set = function(info, key, value)
db.modules[key] = value -- value is boolean
end,-- Table storage
db.modules = {
combat = true,
inventory = false,
map = true,
}
get = function(_, key) return db.modules[key] end,
set = function(_, key, val) db.modules[key] = val end,
-- Set storage (enabled items only)
db.enabledModules = { combat = true, map = true }
get = function(_, key) return db.enabledModules[key] or false end,
set = function(_, key, val)
if val then
db.enabledModules[key] = true
else
db.enabledModules[key] = nil
end
end,Enabled Modules:
[x] Combat Tracker [x] Map Enhancements
[ ] Inventory Manager
A color picker for RGBA values.
{
type = "color",
name = "Background Color",
desc = "Select background color",
hasAlpha = true,
get = function(info)
return db.bgR, db.bgG, db.bgB, db.bgA
end,
set = function(info, r, g, b, a)
db.bgR, db.bgG, db.bgB, db.bgA = r, g, b, a
end,
}| Property | Type | Default | Description |
|---|---|---|---|
hasAlpha |
boolean | false | Show alpha (transparency) slider |
Get returns 3 or 4 values (0-1 range):
get = function(info)
return r, g, b -- RGB only
-- or
return r, g, b, a -- RGBA
end,Set receives 4 parameters:
set = function(info, r, g, b, a)
-- r, g, b, a are all 0-1 range
-- a is always provided (1.0 if hasAlpha = false)
end,-- Separate values
db = { r = 1, g = 0.5, b = 0, a = 0.8 }
get = function() return db.r, db.g, db.b, db.a end,
set = function(_, r, g, b, a)
db.r, db.g, db.b, db.a = r, g, b, a
end,
-- Table storage
db.color = { r = 1, g = 0.5, b = 0, a = 0.8 }
get = function()
local c = db.color
return c.r, c.g, c.b, c.a
end,
set = function(_, r, g, b, a)
db.color = { r = r, g = g, b = b, a = a }
end,
-- Array storage
db.color = { 1, 0.5, 0, 0.8 }
get = function()
return unpack(db.color)
end,
set = function(_, r, g, b, a)
db.color = { r, g, b, a }
end,Swatch button that opens WoW's color picker:
Background Color: [##] <- Colored swatch
A key binding capture button.
{
type = "keybinding",
name = "Toggle Hotkey",
desc = "Press a key to set the binding",
get = function(info) return db.toggleKey end,
set = function(info, value) db.toggleKey = value end,
}Values are strings like:
"A"- Simple key"CTRL-A"- With modifier"CTRL-SHIFT-A"- Multiple modifiers"F12"- Function key"NUMPAD1"- Numpad
get = function(info)
return db.keybind or "" -- Return string
end,
set = function(info, value)
db.keybind = value
-- Optionally set actual WoW binding
SetBinding(value, "MYADDON_ACTION")
end,Toggle Hotkey: [CTRL-SHIFT-A] <- Button
Click to capture, press key combination, press Escape to cancel.
A button that triggers an action when clicked.
{
type = "execute",
name = "Reset Settings",
desc = "Reset all settings to defaults",
func = function(info)
ResetDefaults()
end,
confirm = true,
confirmText = "Are you sure?",
image = "Interface\\Icons\\INV_Misc_QuestionMark",
imageWidth = 24,
imageHeight = 24,
}| Property | Type | Required | Description |
|---|---|---|---|
func |
function | Yes | Click handler: func(info) |
image |
string | No | Icon texture path |
imageCoords |
table | No | Icon crop: {left, right, top, bottom} |
imageWidth |
number | No | Icon width in pixels |
imageHeight |
number | No | Icon height in pixels |
func = function(info)
-- info contains path, handler, etc.
DoSomething()
end,handler = MyAddon,
execute = {
type = "execute",
name = "Reload",
func = "Reload", -- Calls MyAddon:Reload(info)
},{
type = "execute",
name = "Delete All",
confirm = true, -- Uses default confirmation
},
{
type = "execute",
name = "Delete All",
confirm = true,
confirmText = "This will delete everything. Continue?",
},
{
type = "execute",
name = "Delete All",
confirm = function(info)
return db.itemCount > 0 -- Only confirm if items exist
end,
confirmText = function(info)
return string.format("Delete %d items?", db.itemCount)
end,
},[Reset Settings] <- Button
With image:
[Icon] [Reset Settings]
These types display information but don't store values.
A section divider with text.
{
type = "header",
name = "Display Options",
order = 10,
}Only uses common properties:
name- Header textorder- Sort orderhidden- Visibility control
--- Display Options ---
______________________
Static text display for information or help.
{
type = "description",
name = "This is explanatory text that appears in the config panel.",
fontSize = "medium",
image = "Interface\\Icons\\INV_Misc_QuestionMark",
imageCoords = {0, 1, 0, 1},
imageWidth = 32,
imageHeight = 32,
}| Property | Type | Default | Description |
|---|---|---|---|
fontSize |
string | "medium" | "small", "medium", or "large" |
image |
string | nil | Image texture path |
imageCoords |
table | nil | Image crop: {left, right, top, bottom} |
imageWidth |
number | nil | Image width |
imageHeight |
number | nil | Image height |
| fontSize | WoW Font Object |
|---|---|
| "small" | GameFontNormalSmall |
| "medium" | GameFontNormal |
| "large" | GameFontNormalLarge |
[Icon] This is explanatory text that appears
in the config panel.
Display or select a texture.
{
type = "texture",
name = "Background",
image = "Interface\\DialogFrame\\UI-DialogBox-Background",
imageCoords = {0, 1, 0, 1},
imageWidth = 64,
imageHeight = 64,
-- Optional: make it selectable
values = {
["Interface\\Buttons\\WHITE8X8"] = "Solid",
["Interface\\DialogFrame\\UI-DialogBox-Background"] = "Dialog",
},
get = function() return db.texture end,
set = function(_, v) db.texture = v end,
}| Property | Type | Description |
|---|---|---|
image |
string | Texture path to display |
imageCoords |
table | Crop coordinates |
imageWidth |
number | Display width |
imageHeight |
number | Display height |
values |
table/function | Optional selection values |
Display only:
Background: +------+
| |
| tex |
| |
+------+
Select a font from available fonts.
{
type = "font",
name = "Display Font",
desc = "Select the font for text",
values = nil, -- Uses defaults or LibSharedMedia
get = function() return db.fontPath end,
set = function(_, v) db.fontPath = v end,
}| Property | Type | Description |
|---|---|---|
values |
table/function | Optional override values |
If no values provided, includes:
- Friz Quadrata (default)
- Arial Narrow
- Morpheus
- Skurri
If LibSharedMedia-3.0 is available, loads all registered fonts.
Display Font: [Friz Quadrata v] <- Dropdown with font preview
These properties are available on all option types.
| Property | Type | Description |
|---|---|---|
name |
string/function | Display label |
desc |
string/function | Tooltip/description text |
descStyle |
string | "tooltip" or "inline" |
order |
number/function | Sort order (lower = earlier) |
| Property | Type | Description |
|---|---|---|
hidden |
boolean/function | Hide completely |
disabled |
boolean/function | Show but non-interactive |
| Property | Type | Description |
|---|---|---|
width |
string/number | Widget width |
Width values:
"half"- 0.5x normal"normal"- 1.0x (default)"double"- 2.0x"full"- Full container widthnumber- Custom multiplier
| Property | Type | Description |
|---|---|---|
get |
function/string | Value getter |
set |
function/string | Value setter |
validate |
function/string | Validation function |
| Property | Type | Description |
|---|---|---|
confirm |
boolean/function/string | Require confirmation |
confirmText |
string/function | Confirmation message |
| Property | Type | Description |
|---|---|---|
handler |
table | Object for method resolution |
arg |
any | Custom argument in info |
| Property | Type | Description |
|---|---|---|
cmdHidden |
boolean/function | Hidden in CLI |
guiHidden |
boolean/function | Hidden in GUI |
dialogHidden |
boolean/function | Hidden in dialogs |
dropdownHidden |
boolean/function | Hidden in dropdowns |
| Property | Type | Description |
|---|---|---|
icon |
string/function | Icon texture path |
iconCoords |
table/function | Icon texture coordinates |
Most properties can be either static values or functions.
name = "Enable Feature",
hidden = false,
order = 10,Functions receive the info table:
name = function(info)
return "Enable " .. db.featureName
end,
hidden = function(info)
return not db.showAdvanced
end,
order = function(info)
return db.prioritize and 1 or 100
end,function(info)
-- info.options = root options table
-- info.option = current option table
-- info.appName = registered app name
-- info.type = option type
-- info.handler = handler object
-- info.arg = custom arg
-- info[1..n] = path components
endCheck if an option definition is valid:
local valid, errorMsg = ConfigTypes:ValidateOption("range", {
type = "range",
name = "Scale",
-- Missing required min/max
})
if not valid then
print("Error:", errorMsg)
-- "Missing required property 'min' for type 'range'"
endCheck if a value matches expected type:
local isValid = ConfigTypes:CheckType("hello", "string") -- true
local isValid = ConfigTypes:CheckType(123, "number") -- true
local isValid = ConfigTypes:CheckType(func, "string|function") -- trueCheck if type stores values:
ConfigTypes:SupportsGetSet("toggle") -- true
ConfigTypes:SupportsGetSet("group") -- false
ConfigTypes:SupportsGetSet("header") -- false
ConfigTypes:SupportsGetSet("execute") -- falseCheck if type contains other options:
ConfigTypes:IsContainer("group") -- true
ConfigTypes:IsContainer("toggle") -- falseConfigTypes.widthValues = {
half = 0.5,
normal = 1.0,
double = 2.0,
full = "full", -- Special handling
}ConfigTypes.fontSizes = {
small = "GameFontNormalSmall",
medium = "GameFontNormal",
large = "GameFontNormalLarge",
}| Type | Required Props | get/set | Notes |
|---|---|---|---|
| group | args | No | Container, root must be group |
| toggle | - | Yes | Boolean checkbox |
| input | - | Yes | Text input |
| range | min, max | Yes | Numeric slider |
| select | values | Yes | Dropdown/radio |
| multiselect | values | Yes | get(info, key), set(info, key, val) |
| color | - | Yes | get returns r,g,b[,a], set receives info,r,g,b,a |
| keybinding | - | Yes | Key capture |
| execute | func | No | Button action |
| header | - | No | Section divider |
| description | - | No | Static text |
| texture | - | Optional | Display/select texture |
| font | - | Yes | Font selector |
- Config.md - Main configuration system documentation
- ConfigDialog.md - GUI rendering details