Menu
A keyboard-driven menu with banners, submenus, sliders, lists and side panels — fire-and-forget via per-item callbacks.
A keyboard-driven menu with banners, submenus, sliders, lists and side panels — fire-and-forget via per-item callbacks.
lib.menu opens a keyboard-navigable menu (arrows + Enter + Backspace + Escape). It's
fire-and-forget: you react through each item's callbacks, not through a return value.
lib.menu({
title = 'Admin',
items = {
{ type = 'button', label = 'Revive', onSelected = revivePlayer },
{ type = 'checkbox', label = 'God mode', default = false, onChange = toggleGod },
},
})lib.menu(options)
titlestringrequiredMenu title.
itemsMenuItem[]requiredThe list of items (see types below).
bannerstring | tableoptionalOptional banner — an image or a colored band. See Banner below.
itemsPerPagenumberoptionalItems shown before pagination. Default 10.
onClosefunctionoptionalCalled when the root menu closes.
The banner option has three modes:
| Mode | Value | Renders |
|---|---|---|
| Image | string (url / nui://… / data URI) | An image on top, sober header below |
| Colored | { color, text?, textColor? } | A colored band with text (defaults to title); textColor auto-contrasts |
| None | nil | Sober header only (title + counter) |
string (url / nui://… / data URI){ color, text?, textColor? }text (defaults to title); textColor auto-contrastsnil-- Image
lib.menu({ title = 'Garage', banner = 'nui://my_garage/img/banner.png', items = {} })
-- Colored band (text color auto-contrasted)
lib.menu({ title = 'Garage', banner = { color = '#148CE1', text = 'GARAGE' }, items = {} })
-- None (sober header)
lib.menu({ title = 'Garage', items = {} })| Type | Behaviour |
|---|---|
button | Runs onSelected() on Enter — or opens submenu if set. |
checkbox | Toggle; onChange(value) gets the new boolean. default sets the initial state. |
slider | min / max / step; onChange(value) gets the number. |
list | Cycles values[] with left / right; onChange(value) gets the string. |
separator | A visual line (optional label), not focusable. |
buttononSelected() on Enter — or opens submenu if set.checkboxonChange(value) gets the new boolean. default sets the initial state.slidermin / max / step; onChange(value) gets the number.listvalues[] with left / right; onChange(value) gets the string.separatorlabel), not focusable.Any item can carry a panel (title, image, values, statistics, text) to show contextual info on the right when focused.
lib.menu({
title = 'Settings',
items = {
{ type = 'button', label = 'Display', submenu = {
title = 'Display',
items = {
{ type = 'slider', label = 'FOV', min = 30, max = 90, default = 50, onChange = applyFov },
},
}},
},
})lib.closeMenu() closes the whole stack; lib.isMenuOpen() returns a boolean.
lib.menu doesn't block and doesn't return — react via onSelected / onChange. Calling it again replaces the current menu (no stacking). Editing items afterwards has no effect: rebuild the table and call lib.menu again.