> For the complete documentation index, see [llms.txt](https://twisteddev.gitbook.io/introduction/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://twisteddev.gitbook.io/introduction/resources/qb-menu.md).

# qb-menu

## Introduction

* An NUI menu with pressable buttons is very easy to use/edit and very versatile

{% hint style="success" %}
Menu icons can be found on the [Font Awesome](https://fontawesome.com/) website
{% endhint %}

## Preview

![](/files/FuDE2JihqcitR10qMgZl)

![](/files/daHwAgXZgJ60fmW5S8YA)

## Usage Example

### Static menu

{% hint style="warning" %}
Examples are done on the CLIENT side
{% endhint %}

```etlua
RegisterCommand('qbmenutest', function()
    exports['qb-menu']:openMenu({
        {
            header = 'QBCore Test Menu',
            icon = 'fas fa-code',
            isMenuHeader = true, -- Set to true to make a nonclickable title
        },
        {
            header = 'First Button',
            txt = 'Print a message!',
            icon = 'fas fa-code-merge',
            params = {
                event = 'qb-menu:client:testButton',
                args = {
		    message = 'This was called by clicking a button'
                }
            }
        },  
        {
            header = 'Second Button',
            txt = 'Open a secondary menu!',
            icon = 'fas fa-code-pull-request',
            -- disabled = false, -- optional, non-clickable and grey scale
            -- hidden = true, -- optional, hides the button completely
            params = {
                -- isServer = false, -- optional, specify event type
                event = 'qb-menu:client:subMenu',
                args = {
                    number = 2,
                }
            }
        },
    })
end)

RegisterNetEvent('qb-menu:client:subMenu', function(data)
    local number = data.number
    exports['qb-menu']:openMenu({
        {
            header = 'Return to main menu',
            icon = 'fa-solid fa-backward',
            params = {
                event = 'qb-menu:client:mainMenu',
                args = {}
            }
        },
        {
            header = 'Sub-menu button',
            txt = 'Print a message!',
            icon = 'fas fa-code-merge',
            params = {
                event = 'qb-menu:client:testButton',
                args = {
		    message = 'This was called by clicking a button'
                }
            }
        }
    })
end)

RegisterNetEvent('qb-menu:client:mainMenu', function()
    ExecuteCommand('qbmenutest')
end)

RegisterNetEvent('qb-menu:client:testButton', function(data)
    print(data.message)
end)
```

### For loop menu

```etlua
local staff = { -- our table we will loop through to get button values
    ['Kakarot'] = 'Dictator',
    ['Kings'] = 'Pleb',
    ['Griefa'] = 'Toxic',
    ['Fish'] = 'Sexy'
}

RegisterCommand('qbmenutable', function()
    local staffList = {}
    staffList[#staffList + 1] = { -- create non-clickable header button
        isMenuHeader = true,
        header = 'QBCore Test Loop Menu',
        icon = 'fa-solid fa-infinity'
    }
    for k,v in pairs(staff) do -- loop through our table
        staffList[#staffList + 1] = { -- insert data from our loop into the menu
            header = k,
            txt = 'Yeah they are definitely '..v,
            icon = 'fa-solid fa-face-grin-tears',
            params = {
                event = 'example:client:notify', -- event name
                args = {
                    name = k, -- value we want to pass
                    label = v
                }
            }
        }
    end
    exports['qb-menu']:openMenu(staffList) -- open our menu
end)

RegisterNetEvent('example:client:notify', function(data)
    print('My favorite QBCore staff member is the '..data.label..' '..data.name)
end)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://twisteddev.gitbook.io/introduction/resources/qb-menu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
