Dropdown
Dropdowns present selectable lists with optional search, multi-select, and formatter support.
Playground
A dropdown
Control dropdown height
Allow selecting multiple values
Permit clearing the selection
Enable searching through values
Usage
You can create a Dropdown by calling the AddDropdown method on a Groupbox.
Arguments
local Dropdown = Groupbox:AddDropdown("MyDropdown", {
Text = "A dropdown",
Values = { "This", "is", "a", "dropdown" },
Default = 1,
Multi = false,
})| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Index/ID of the dropdown | string | nil |
| 2 | Dropdown configuration table | table | nil |
Configuration Table
Prop
Type
Methods
You can use the following methods to interact with the dropdown:
SetValue
Sets the selected value or values.
Dropdown:SetValue(value)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Value to select (string, number, or table) | any | nil |
SetValues
Replaces all dropdown values.
Dropdown:SetValues(table)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | New values list | table | nil |
AddValues
Adds new values to the dropdown.
Dropdown:AddValues(value)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Value or table of values to add | any | nil |
SetDisabledValues
Sets which values are disabled.
Dropdown:SetDisabledValues(table)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Table of values to disable | table | nil |
AddDisabledValues
Adds values to the disabled list.
Dropdown:AddDisabledValues(value)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Value or table of values to disable | any | nil |
SetValueImages
Replaces value to image mapping.
Dropdown:SetValueImages(table)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Table mapping values to images | table | nil |
AddValueImages
Adds new value to image mapping into the existing ones.
Dropdown:AddValueImages(table)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Table mapping values to images to add | table | nil |
SetText
Updates the dropdown's label text.
Dropdown:SetText(text)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | New label text | string | nil |
SetDisabled
Enables or disables the dropdown.
Dropdown:SetDisabled(boolean)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Whether to disable the dropdown | boolean | nil |
SetVisible
Shows or hides the dropdown.
Dropdown:SetVisible(boolean)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Whether to show the dropdown | boolean | nil |
GetActiveValues
Returns the currently selected values.
local values = Dropdown:GetActiveValues()
local count = Dropdown:GetActiveValues(true)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Return count | boolean? | false |
OnChanged
Adds another callback function.
Dropdown:OnChanged(function)| Arg Idx | Argument Description | Type | Default |
|---|---|---|---|
| 1 | Callback executed when the dropdown changes | function | nil |
Example
local Options = Library.Options
local Dropdown = Groupbox:AddDropdown("MyDropdown", {
Text = "A dropdown",
Values = { "This", "is", "a", "dropdown" },
Default = 1,
})
Options.MyDropdown:OnChanged(function()
print("Selected value:", Options.MyDropdown.Value)
end)
Options.MyDropdown:SetValue("This")