Context

Library
Updated 2 months ago · v1.3.7

Context Menus

lib.registerContext

Register a context menu that can be opened by ID

lua
lib.registerContext('my_menu', {
    title = 'Main Menu',
    icon = 'fa-bars',
    options = {
        {
            title = 'Option 1',
            description = 'Does something',
            icon = 'fa-cog',
            onSelect = function()
                print('selected!')
            end,
        },
        {
            title = 'Sub Menu',
            icon = 'fa-arrow-right',
            arrow = true,
            menu = 'my_sub_menu', -- opens another registered context
        },
    },
})
ParameterTypeRequiredDescription
idstringyesUnique menu identifier
datatableyesMenu definition (see below)
FieldTypeDescription
titlestringMenu header title
iconstringFontAwesome icon class
optionstable[]Array of menu options

Option Fields

FieldTypeDescription
titlestringOption label
descriptionstringSubtitle text
iconstringFontAwesome icon
onSelectfunctionCallback when selected
menustringID of a sub-menu to open
dialogstringID of a dialog to open
argsanyArguments passed to clientEvent / serverEvent
clientEventstringTrigger a client event when selected
serverEventstringTrigger a server event when selected
metadatatableKey-value pairs displayed as badges
disabledbooleanGrey out the option
arrowbooleanShow a right arrow
willClosebooleanForce option to close (or keep open) before callbacks

lib.openContext

Open a registered context menu

lua
lib.openContext('my_menu')

lib.closeContext

Close the currently open context menu

lua
lib.closeContext()

lib.getOpenContextMenu

Get the ID of the currently open context menu

lua
local id = lib.getOpenContextMenu()

lib.showContext / lib.hideContext

Show or hide the context menu without destroying it

lua
lib.showContext()
lib.hideContext()
Was this page helpful?
This page was last updated on 12 March 2026
DIRKSCRIPTS
All you need for your FiveM server.10% off your first order

Unsubscribe any time.

Copyright © 2026 DirkScripts. Not affiliated with or endorsed by Rockstar North or Take-Two Interactive.