Tabs
A tab bar with one panel per tab, showing the picked one: a shop’s sections, a booth’s queue and effects. The bar is a Toggle Group where a tab stays picked.


Lucy.Tabs.new({
items = {
{ value = "emotes", text = "Emotes", content = Lucy.Stack.new({
direction = "horizontal",
gap = "Space2",
children = {
Lucy.Button.new({ text = "Moonwalk 300", icon = "lucide-extended:coins-filled", variant = "outline" }),
Lucy.Button.new({ text = "Robot 150", icon = "lucide-extended:coins-filled", variant = "outline" }),
Lucy.Button.new({ text = "Twirl 50", icon = "lucide-extended:coins-filled", variant = "outline" }),
},
}) },
{ value = "outfits", text = "Outfits", content = Lucy.Text.new({ text = "New outfits drop every Friday", variant = "muted" }) },
},
Parent = parent,
})
Props
| Prop | Type | Default | State key | What it does |
|---|---|---|---|---|
items | table | The tabs, in order (see below) | ||
value | any | the first tab | yes | The tab shown |
variant | string | "default" | yes | The tab bar’s look: default, outline, line for text tabs with a line under the picked one, or segmented for a pill as tall as a control of its size (Toggle Group) |
size | string | "md" | yes | The tab bar’s size: sm, md, lg or xl, each as tall as a Button of the same size |
gap | spacing | "Space2" | Space between the tab bar and the panels | |
shoulderButtons | boolean | true | LB and RB switch tabs while focus is inside | |
hints | boolean | follows shoulderButtons | Shows LB and RB either side of the bar on a controller. true keeps them with shoulderButtons = false, for a game that handles LB and RB itself | |
scroll | boolean | true | A tab bar too long for its room scrolls sideways. false makes the bar as wide as its tabs; with no panels, the tabs then fit the bar, to sit in a row beside other controls | |
mount | string | "shown" | When a panel made by a function is built: "shown" the first time its tab shows, "immediate" when the tabs are made (Building panels) | |
keep | boolean | true | false removes a panel when another tab shows and builds it again when the player comes back. With mount = "shown" only | |
disabled | boolean | false | yes | Greys every tab out and ignores clicks |
visible | boolean | true | yes | Shows or hides it |
onValueChange | function | Called with (value, handle) when it changes |
It also takes the props every component takes.
Each tab is a table:
| Field | What it does |
|---|---|
value | What the tab stands for. Required |
text | The tab’s text. Defaults to the value. label works too |
content | The panel: an Instance, a handle, or a function that makes it (Building panels). Leave it out of every tab for a bar on its own, picking what one shared view shows (a leaderboard’s board) |
icon | An icon name drawn before the tab’s text |
children | Anything after the text in the tab’s slot, such as a count badge. With an icon or children and no text, the tab shows no text. They take the tab’s colours |
disabled | Greys this tab out |
visible | Shows or hides this tab: true, false, a ref or a getter. A hidden tab leaves the bar and cannot be picked. Defaults to true |
Tabs fill the width and grow to fit the panel shown. Put a Scroll Area in a panel for long content.
Building panels
Give a tab’s content as a function and its panel is built the first time the tab shows, however it comes to show: the player picks it, LB or RB reach it, or the game writes its value. A shop with six tabs builds one when it opens, and the others only if the player looks at them. Once built a panel is kept: switching back to a tab finds it as the player left it, scrolled to the same place.
The function is called with the panel’s frame. What it parents to the frame stays, and an Instance or a handle it returns is put in the frame:
{ value = "moves", text = "Moves", content = function(panel)
return Lucy.Stack.new({ gap = "Space2", children = buildMoveRows() })
end }
keep = falseremoves a panel when another tab shows, and builds it again when the player comes back. Use it for big panels the player seldom opens. A removed panel starts afresh, so keep what must last (a search box’s text) in app state.mount = "immediate"builds every panel when the tabs are made, for a panel that must exist before its tab shows.tabs:build(value)builds one tab’s panel ahead of time without showing it, so the first switch to it is instant.
Content made ahead of time (an Instance or a handle, not a function) is placed when the tabs are made and always kept.
Until a tab is built, the components inside it do not exist: code that reaches into a tab the player has not seen (app:handle(id), ui.<id>) calls tabs:build(value) first.
In a Dialog or a Sheet, whose body scrolls, put the tab bar in its header so it stays put while a long panel scrolls under it. tabs.bar is the bar with its LB and RB hints:
local tabs = Lucy.Tabs.new({ items = items })
Lucy.Sheet.new({ title = "Booth", header = { tabs.bar }, children = { tabs } })
When the player picks a tab, it reports select with the tab’s value for useUiSound.
Gamepad
While focus is anywhere inside the tabs, on the tab bar or in a panel, LB and RB move to the previous and next tab, skipping disabled and hidden ones and wrapping around at the ends. That holds for a bar moved into a Dialog or Sheet’s header too: the bar is still the tabs’ part (Lucy’s input follows the component tree, as a portal does). If focus was in the old panel, it moves to the first thing the player can select in the new one, otherwise to the new tab. With tabs inside tabs, the inner ones switch. On a controller, and only there, LB and RB show either side of the tabs (hints), drawn as the player’s own controller buttons and centred on the tabs. Line tabs hug their words, so LB sits just before the first tab and RB just after the last.
A tab bar too long for its room scrolls sideways, its edges fading where there are more tabs. On touch the player drags it. With a controller or the keyboard, moving along the tabs scrolls the bar with them, and the picked tab is always brought into view, however it was picked.
handle.list is the tab bar, handle.bar the row it sits in with its hints (the list itself without hints), handle.hints the two Kbd hints (back and forward, nil without hints), and handle.panels maps each tab’s value to its panel frame, empty until that tab is built.
Methods
| Name | What it does |
|---|---|
tabs:select(value) | Shows that tab, as if the player picked it |
tabs:build(value?) | Builds that tab’s panel now without showing it. Left out, the shown tab’s. Does nothing for a panel already built |
Examples
Text tabs with a line under the picked one, for the sections of a big menu. Line tabs have no side padding, so the first tab’s words line up with the content’s edge, and the bold line sits a little under the words:


Lucy.Tabs.new({
variant = "line",
items = {
{ value = "moves", text = "Moves", content = buildMoves },
{ value = "packs", text = "Packs", content = buildPacks },
{ value = "drinks", text = "Drinks", content = buildDrinks },
},
Parent = shop,
})
Every crew member’s set list, more than fit across a phone. The bar scrolls:


local crew = { "DJ Lucy", "Nova", "Beatrix", "Kai", "Juno", "Remy", "Pixel Pulse", "The Glowsticks" }
local items = {}
for _, name in crew do
table.insert(items, {
value = name,
text = name,
content = function() return Lucy.Text.new({ text = `{name}'s set list`, variant = "muted" }) end,
})
end
local box = Lucy.new("Frame")({ Size = UDim2.fromOffset(360, 120), BackgroundTransparency = 1, Parent = parent })
Lucy.Tabs.new({ variant = "line", items = items, value = "Kai", Parent = box })
Open the shop on a tab kept in app state:


local section = app.state:ref("shop.section")
Lucy.Tabs.new({
value = section,
items = {
{ value = "emotes", text = "Emotes", content = buildEmotes },
{ value = "outfits", text = "Outfits", content = buildOutfits },
},
Parent = shop,
})
-- From anywhere, such as a "new outfit" toast:
section("outfits")
Preview
In Studio, from the command bar: Lucy.Preview.show("Tabs").