Select
A button that opens a list of options to pick one from: a server region, a sort order, a game mode. It shows the option picked, or a placeholder until there is one.

Lucy.Stack.new({
gap = "Space2",
children = {
Lucy.Text.new({ text = "Next set", variant = "label" }),
Lucy.Select.new({
id = "genre",
placeholder = "Genre",
value = "house",
items = {
{ value = "house", label = "House" },
{ value = "disco", label = "Disco" },
"Techno",
},
onValueChange = function(value)
app.toast(`Next set: {value}`)
end,
}),
},
Parent = parent,
})
Props
| Prop | Type | Default | State key | What it does |
|---|---|---|---|---|
items | table | The options, see Items | ||
value | any | false | yes | The value picked, or false for none yet. With multiple, an array |
type | string | "default" | default or check, see Types | |
multiple | boolean | false | Lets the player pick several (a check select) | |
placeholder | string | "Select" | yes | Shown until something is picked |
open | boolean | false | yes | Whether the list is open |
disabled | boolean | false | yes | Stops the player opening it, and closes it |
size | string or UDim2 | "md" | yes | sm, md, lg or xl: the button fills the width at the height and text of a Button of the same size, so they line up in a row or a form. A UDim2 sets the button's box instead |
side | string | "bottom" | bottom, top, left or right: where the list opens. It flips when the other side has more room. auto opens below if it fits, then above, then beside | |
align | string | "start" | start, center or end: how the list lines up with the button | |
onValueChange | function | Called with (value, handle) when the value changes | ||
mount | string | "shown" | When the list and its options are built: "shown" the first time it opens, "immediate" when the select is made | |
keep | boolean | true | false takes the list away once it has closed and builds it again on the next open. With mount = "shown" only | |
onBuild | function | Called with the select once its list and options exist, each time they are built, before it shows | ||
preload | list or function | Its pictures, or a function returning them, read when needed. Warmed by warm(), and first in the queue when it opens. See Warming ahead | ||
trigger | button, handle or list | What opens it. Hovered or focused, it warms (it does not open) | ||
ahead | overlays or function | Overlays warmed when this one opens, such as a sheet opened from inside it | ||
visible | boolean | true | yes | Shows or hides it |
It also takes the props every component takes.
Items
An item is a value, shown as its text, or a table with value, and optionally
label (or text; both work), icon, children and disabled. A disabled option shows faded and cannot be picked.
An option is a row with a slot: its icon, label and children
(a flag, a count, a badge) sit in a row past the tick, in the option's colours.
The label fills the row and truncates; the select's button shows the label
alone, so give an option with children a label too.
Types
default: the picked option is highlighted in the list.check: a tick in front of the picked option.
With multiple = true the select is a check select where the player can
pick several. Each press ticks or unticks an option and the list stays open.
The value is an array in the order of items, and the button shows the first
label and how many more, such as "Pop +2".

Lucy.Select.new({
multiple = true,
placeholder = "Genres",
items = { "Pop", "Hip hop", "House", "Techno" },
onValueChange = function(genres)
app.toast(`{#genres} genres in the mix`)
end,
})
How it opens
The list and its options are built the first time it opens, before anything
sees it open, so a form with many selects pays only for the buttons. The button
shows the value from items without them. The first time the list shows, it
waits one frame off the screen while its text is measured.
The list opens on the app's overlay layer, above everything opened before it:
- Mouse and keyboard: under the button (or above it when there is more room there), at least as wide as the button.
- Gamepad: the same, with the option already picked selected. When it closes, the button is selected again.
- Touch: a drawer from the bottom of the screen, where a thumb can reach it. It slides up (it just appears with reduced motion) and leaves room above a phone's home bar.
A long list scrolls inside the space it has. B, Backspace or a press outside closes it without changing anything.
The button draws lucy:chevron-down, and a check select draws lucy:check.
To use your own, see Icons Lucy draws.
Methods and events
| Name | What it does |
|---|---|
select:select(value) | Picks value as if the player had, and closes the list. With multiple, ticks or unticks it |
select:open() | Opens the list |
select:close() | Closes the list |
select:toggle() | Opens it if closed, closes it if open |
select:build() | Builds the list and its options now without opening it. Does nothing once they are built |
select.items | One { root, label, check } per option, in order (nil until built) |
select.content, select.list | The list and its scroll area (nil until built) |
select.presentation() | "popup" or "drawer", for this opening |
When the player picks an option, it reports select with the value, for
game sounds.
Examples
Read or change the value from anywhere by its id:
app.state:get("ui.genre.value")
app.state:set("ui.genre.value", "disco")
Keep it in step with a ref:

local sort = Lucy.ref("newest")
Lucy.Select.new({
value = sort,
items = {
{ value = "newest", label = "Newest" },
{ value = "popular", label = "Most played" },
},
})
Preview
In Studio, from the command bar: Lucy.Preview.show("Select").