Skip to Content

Menu

Keyboard-navigable list menus with side-scroll values, checkboxes, and icons.

Client Exports

registerMenu

Register a menu with a change handler callback.

exports['trinity-ui']:registerMenu(data, cb)

Menu Properties:

PropertyTypeRequiredDescription
idstringYesUnique menu identifier
titlestringYesMenu title
optionstable[]YesArray of menu items
positionstring'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
disableInputbooleanDisable player movement while open
canClosebooleanWhether the menu can be closed (default true)
onClosefunction(keyPressed)Called when menu closes
onSelectedfunction(selected, scrollIndex, args)Called on item selection
onSideScrollfunction(selected, scrollIndex, args)Called on side-scroll value change
onCheckfunction(selected, checked, args)Called on checkbox toggle

cb — Legacy callback: function(selected, scrollIndex, args, checked)

Option Properties:

PropertyTypeDescription
labelstringItem text (required)
iconstringIconify icon name
iconColorstringIcon color (hex)
descriptionstringSecondary text
progressnumberProgress bar (0-100)
colorSchemestringColor scheme for the item
valuestableSide-scroll options (e.g. {'Low', 'Medium', 'High'})
defaultIndexnumberDefault side-scroll index
checkedbooleanShow checkbox (initial state)
argstableCustom data passed to callbacks
closebooleanClose menu on select (default true)

showMenu

Open a registered menu.

exports['trinity-ui']:showMenu(id, startIndex)
ParameterTypeDescription
idstringMenu ID
startIndexnumberOptional starting selection index

hideMenu

Close the currently open menu.

exports['trinity-ui']:hideMenu()

setMenuOptions

Update the options of a registered menu.

exports['trinity-ui']:setMenuOptions(id, options, index)
ParameterTypeDescription
idstringMenu ID
optionstable | table[]New option(s)
indexnumberIf provided, replaces a single option at this index

getOpenMenu

Returns the ID of the currently open menu, or nil.

local id = exports['trinity-ui']:getOpenMenu()

Example

exports['trinity-ui']:registerMenu({ id = 'vehicle_settings', title = 'Vehicle Settings', position = 'top-left', options = { { label = 'Engine', icon = 'fa6-solid:gear', description = 'Toggle engine on/off', }, { label = 'Window Tint', icon = 'fa6-solid:car-side', values = { 'None', 'Light', 'Medium', 'Dark', 'Limo' }, defaultIndex = 1, description = 'Scroll left/right to change' }, { label = 'Neon Lights', icon = 'fa6-solid:lightbulb', checked = false, description = 'Toggle neon underglow' } }, onSelected = function(selected, scrollIndex, args) if selected == 1 then print('Engine toggled') end end, onSideScroll = function(selected, scrollIndex, args) print('Tint changed to index: ' .. scrollIndex) end, onCheck = function(selected, checked, args) print('Neon lights: ' .. tostring(checked)) end }) exports['trinity-ui']:showMenu('vehicle_settings')

While a menu is open, weapon firing and the weapon wheel are automatically disabled.

Last updated on