> For the complete documentation index, see [llms.txt](https://brady-xyz.gitbook.io/maclib-ui-library/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brady-xyz.gitbook.io/maclib-ui-library/getting-started/loading-maclib/creating-a-window/creating-a-tab-group/adding-tabs/adding-sections/dropdown.md).

# Dropdown

<figure><img src="/files/K2V0t1a5eEp6b3lthLfW" alt=""><figcaption></figcaption></figure>

```lua
Section:Dropdown({
  Name <string>
  Search <boolean> -- Enable searching?
  Multi <boolean> -- Allow multiple choices?
  Required <boolean> -- Force the user to select at minimum one choice?
  Options <table>
  Default <number or table> -- If Multi is enabled, you must input a table of every option name that you want enabled. If Multi is disabled you must input the order (index) in which the default option is at.
  Callback <function(): string or table> -- Multi Dropdowns return a table like such {"Option 1" = true, "Option 3" = true,} Single Dropdowns return the name (no table) of the selected option
}, <string or nil> Flag)
```

Functions

```lua
:UpdateName(<string>)
:SetVisiblity(<boolean>)
:UpdateSelection(<string or number or table>) -- string/number for single, table for multi
:InsertOptions(<table>)
:RemoveOptions(<table>)
:IsOption(<string>: boolean)
:GetOptions(: table) -- Returns a table of every option and if it's true or false (Example: {"Option 1" = true, "Option 2" = false, "Option 3" = false} etc..)
:ClearOptions()

.Value : string or table
.IgnoreConfig <boolean>
.Settings : table -- Not everything may be updated, but Callback should be correct.
```

Examples

```lua
sections.MainSection1:Dropdown({
	Name = "Give Weapons",
	Search = true,
	Multi = true,
	Required = false,
	Options = {"AK-47", "M4A1", "Desert Eagle", "AWP", "MP5", "SPAS-12"},
	Default = {"M4A1", "AWP"},
	Callback = function(Value)
		local Values = {}
		for _, State in next, Value do
			if State then
				table.insert(Values, _)
			end
		end
		print("Selected Weapons:", table.concat(Values, ", "))
	end,
}, "GiveWeaponsDropdown")
```
