The Quasar menu component, q-menu, is a popup that attaches itself to whatever element it's placed in. Put it inside a button and you have a dropdown. Add one prop and it becomes a right-click context menu. Nest one inside another and you have submenus. This post goes through each of those with working code, explains how anchor, self and offset really position the popup (the offset part surprises most people), and ends with when q-btn-dropdown does the same job with less markup. Everything is checked against Quasar 2.35.2.
q-menu goes inside its trigger, as a direct child. Quasar renders the popup itself at the end of <body>, so it never inherits the trigger's styles or gets clipped by an overflow: hidden parent.
<template>
<q-btn flat no-caps label="Account" icon-right="expand_more" aria-haspopup="menu">
<q-menu>
<q-list role="menu" style="min-width: 180px">
<q-item v-close-popup clickable to="/settings">
<q-item-section avatar><q-icon name="settings" /></q-item-section>
<q-item-section>Settings</q-item-section>
</q-item>
<q-item v-close-popup clickable to="/billing">
<q-item-section avatar><q-icon name="receipt_long" /></q-item-section>
<q-item-section>Billing</q-item-section>
</q-item>
<q-separator />
<q-item v-close-popup clickable @click="logOut">
<q-item-section avatar><q-icon name="logout" /></q-item-section>
<q-item-section>Log out</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</template>Clicking an item doesn't close the menu by itself. There are two ways to do it:
v-close-popup on each item, as above. Items without it (a toggle, a search field) keep the menu open.auto-close on the q-menu. Any click inside closes it. Simpler, but it also closes on a click on a toggle or a text field.role="menu" on the list makes the clickable items menuitems for screen readers, and since the role sits on the list rather than on q-menu, the aria-haspopup="menu" on the button is yours to add. q-menu keeps aria-expanded on the button in sync for you. Escape closes the menu and returns focus to the button.
To turn a menu off conditionally, use v-if on the q-menu. The Quasar docs call this out: v-show doesn't work for it.
Two props place the menu, each taking a vertical and a horizontal word:
anchor: the point on the trigger. Default bottom start.self: the point on the menu that's pinned to it. Default top start.So by default the menu's top-left corner sits on the trigger's bottom-left corner. start and end flip for right-to-left languages; left and right don't. Some common placements:
| Placement | anchor | self |
|---|---|---|
| Below, left edges aligned (default) | bottom start | top start |
| Below, right edges aligned | bottom end | top end |
| Below, centered | bottom middle | top middle |
| To the right (submenus) | top end | top start |
| Above, centered | top middle | bottom middle |
If the menu doesn't fit on the requested side, Quasar opens it on the opposite side when that side has more room, and otherwise keeps it where you asked and limits its size to the space available. You don't need to handle "the dropdown at the bottom of the page" yourself.
Three more props shape it:
fit makes the menu at least as wide as its trigger, which is what you want under a full-width button or a search field.cover puts the menu on top of its trigger, like a native select. self and offset stop applying.max-height and max-width cap the size (with units: max-height="300px"). A long list scrolls inside the menu.offset takes two numbers, but it doesn't move the menu by that many pixels. It grows the trigger's box outward ([x, y] pushes the left and right edges out by x, the top and bottom by y), and the menu is then aligned to the bigger box. Two consequences:
bottom start, :offset="[0, 8]" gives an 8px gap below the trigger, as expected.middle or center anchor, the offset on that axis does nothing, because growing both edges equally leaves the middle where it was. anchor="bottom middle" with :offset="[20, 0]" doesn't shift the menu sideways.If you want a horizontal nudge on a centered menu, change anchor and self instead, or add margin inside the menu content.
context-menu makes the menu open on a right-click instead of a left-click, and on a long press on touch devices. It opens where the pointer is, so it feels like a native context menu:
<script setup lang="ts">
interface FileRow {
id: number
name: string
}
const files: FileRow[] = [
{ id: 1, name: 'invoice-1042.pdf' },
{ id: 2, name: 'contract-acme.docx' },
]
function rename(file: FileRow) { /* ... */ }
function remove(file: FileRow) { /* ... */ }
</script>
<template>
<q-list bordered separator>
<q-item v-for="file in files" :key="file.id">
<q-item-section avatar><q-icon name="description" /></q-item-section>
<q-item-section>{{ file.name }}</q-item-section>
<q-item-section side>
<q-btn flat round dense icon="more_vert" :aria-label="`Actions for ${file.name}`" aria-haspopup="menu">
<q-menu anchor="bottom end" self="top end">
<FileActions :file="file" @rename="rename" @remove="remove" />
</q-menu>
</q-btn>
</q-item-section>
<q-menu context-menu>
<FileActions :file="file" @rename="rename" @remove="remove" />
</q-menu>
</q-item>
</q-list>
</template>FileActions is a small component holding the q-list role="menu" with Rename and Delete items, each with v-close-popup, so both menus share the same markup.
Why two menus for one row? A context menu has no keyboard path: it listens for right-click and long press only, and Quasar deliberately doesn't add aria-expanded to its trigger, since the row isn't a control you activate. Keyboard and screen reader users would never find the actions. The visible ⋮ button gives them a way in, and the right-click is a shortcut for mouse users. Mobile users get both: a long press and a tap on the button.
The Quasar docs' context menu examples also add touch-position. On a regular (left-click) menu, touch-position is what places the popup at the click point rather than at the anchor; a context menu already opens at the pointer.
A submenu is a q-menu inside a q-item of the parent menu, opened to the side:
<template>
<q-btn flat no-caps label="File" aria-haspopup="menu">
<q-menu>
<q-list role="menu" dense style="min-width: 160px">
<q-item v-close-popup clickable>
<q-item-section>New</q-item-section>
</q-item>
<q-item clickable aria-haspopup="menu">
<q-item-section>Export as</q-item-section>
<q-item-section side><q-icon name="chevron_right" /></q-item-section>
<q-menu anchor="top end" self="top start">
<q-list role="menu" dense>
<q-item v-for="format in ['PDF', 'CSV', 'XLSX']" :key="format" v-close-popup clickable>
<q-item-section>{{ format }}</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-item>
</q-list>
</q-menu>
</q-btn>
</template>Nested menus form a chain, and v-close-popup treats the chain as one popup: clicking "CSV" closes the submenu and the parent together. If a submenu should close on its own, give it separate-close-popup.
Quasar 2.26 added a hover prop, so menus can open on hover too. Click, tap and keyboard keep working, so touch devices fall back to tapping. hover-delay and hover-hide-delay (150ms by default) tune the timing, and hovering from a menu into its submenu keeps the chain open. It's a good fit for desktop menu bars; it has no effect on a context menu.
v-model controls a menu from outside its trigger:
<script setup lang="ts">
import { ref } from 'vue'
const query = ref('')
const open = ref(false)
</script>
<template>
<q-input v-model="query" label="Search" @focus="open = true">
<q-menu v-model="open" fit no-parent-event no-focus no-refocus>
<!-- suggestions -->
</q-menu>
</q-input>
</template>no-parent-event stops the input's own clicks from toggling the menu, so only your code opens it. no-focus keeps the cursor in the input when the menu opens, and no-refocus stops focus from jumping back when it closes. For a menu that should stay open on outside clicks and Escape, add persistent. The show(), hide() and toggle() methods do the same through a template ref, and updatePosition() re-checks the placement after you swap the menu's content while it's open.
If the trigger is a button and the content is a list of actions, q-btn-dropdown is a q-btn and a q-menu in one tag, with the arrow icon included:
<template>
<q-btn-dropdown split color="primary" no-caps label="Save" @click="save">
<q-list role="menu">
<q-item v-close-popup clickable @click="saveAsDraft">
<q-item-section>Save as draft</q-item-section>
</q-item>
<q-item v-close-popup clickable @click="saveAndClose">
<q-item-section>Save and close</q-item-section>
</q-item>
</q-list>
</q-btn-dropdown>
</template>With split, the label half runs the main action (@click fires only for it) and the arrow half opens the menu. Without split, the whole button opens the menu. It takes the usual button props (color, flat, outline, icon) and menu props with a menu- prefix: menu-anchor and menu-self default to bottom end and top end, so the menu lines up with the button's right edge. auto-close, persistent, cover, menu-offset and hover work as on q-menu, and toggle-aria-label labels the arrow for screen readers.
Use q-menu when the trigger isn't a button (an avatar, a table row, a whole card), when you need a context menu, or when the content is a card rather than a list.
How do I close a QMenu when an item is clicked? Add v-close-popup to the item, or auto-close to the menu.
How do I make a QMenu as wide as its button? Add fit.
Why does my menu open above the button? There wasn't enough room below it and more room above, so Quasar flipped it. Give the page more space below the trigger, or cap the menu with max-height.
Can one QMenu serve many triggers? Yes: set target to a CSS selector or an element, and the menu attaches to that instead of its parent.
For menus that are more than a list, see the Flyout Menus: 6 designs, 1 of them Free. The Free one is a classic list menu with separators; the others are cards with titled items and descriptions, icon items with a footer of actions or recent posts, a two-column panel, and a wide three-column menu for a site header.