Documentation
Select

Select

Select is a Tree component that collects user-provided information from a list of options.

Usage Example

local signal = n.create_signal({ 
  selected = { "poland" }
})
 
n.select({
  border_label = "Select countries",
  selected = signal.selected,
  data = {
    n.separator("Europe"),
    n.option("Poland", { id = "poland" }),
    n.option("Spain", { id = "spain" }),
    n.option("Portugal", { id = "portugal" }),
    n.option("France", { id = "france" }),
    n.option("Germany", { id = "germany" }),
    n.separator("North America"),
    n.option("USA", { id = "usa" }),
    n.option("Canada", { id = "canada" }),
  },
  multiselect = true,
  on_select = function(nodes)
    signal.selected = nodes
  end,
})

Properties

data

Type
NuiTreeNode[]

multiselect

Default value
false
Type
boolean

selected

If multiselect is set to true:

Type
string[] | NuiTreeNode[]

Otherwise:

Type
string | NuiTreeNode

on_select

If multiselect is set to true:

Type
fun(selected: NuiTreeNode[], component: Select): nil

Otherwise:

Type
fun(selected: NuiTreeNode, component: Select): nil

prepare_node

Type
fun(is_selected: boolean, node: NuiTreeNode, component: Select): NuiLine

should_skip_item

Type
fun(node: NuiTreeNode, is_separator: boolean): NuiLine

Highlight Groups

  • NuiComponentsSelectOption
  • NuiComponentsSelectOptionSelected
  • NuiComponentsSelectSeparator
  • NuiComponentsSelectNodeFocused