LogoObsidian

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 IdxArgument DescriptionTypeDefault
1Index/ID of the dropdownstringnil
2Dropdown configuration tabletablenil

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 IdxArgument DescriptionTypeDefault
1Value to select (string, number, or table)anynil

SetValues

Replaces all dropdown values.

Dropdown:SetValues(table)
Arg IdxArgument DescriptionTypeDefault
1New values listtablenil

AddValues

Adds new values to the dropdown.

Dropdown:AddValues(value)
Arg IdxArgument DescriptionTypeDefault
1Value or table of values to addanynil

SetDisabledValues

Sets which values are disabled.

Dropdown:SetDisabledValues(table)
Arg IdxArgument DescriptionTypeDefault
1Table of values to disabletablenil

AddDisabledValues

Adds values to the disabled list.

Dropdown:AddDisabledValues(value)
Arg IdxArgument DescriptionTypeDefault
1Value or table of values to disableanynil

SetText

Updates the dropdown's label text.

Dropdown:SetText(text)
Arg IdxArgument DescriptionTypeDefault
1New label textstringnil

SetDisabled

Enables or disables the dropdown.

Dropdown:SetDisabled(boolean)
Arg IdxArgument DescriptionTypeDefault
1Whether to disable the dropdownbooleannil

SetVisible

Shows or hides the dropdown.

Dropdown:SetVisible(boolean)
Arg IdxArgument DescriptionTypeDefault
1Whether to show the dropdownbooleannil

OnChanged

Adds another callback function.

Dropdown:OnChanged(function)
Arg IdxArgument DescriptionTypeDefault
1Callback executed when the dropdown changesfunctionnil

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")

On this page