Menu
Alpha.10
Available in Mavis alpha.11 for Vue Web and NativeScript. Keep core and renderer versions aligned.
<MMenu
v-model:open="open"
label="Actions"
triggerLabel="Actions"
:items="actions"
@select="onAction"
/>| Property | Type | Default | Description |
|---|---|---|---|
items | MenuItem[] | required | Actions with stable value, label, icon, disabled and destructive; or group/separator with unique key. |
open / v-model:open | boolean | false | Controlled visibility. |
label / triggerLabel | string | required | Menu name and trigger text. |
placement / width | Popover props | bottom-start / 280 | Shared anchored presentation. |
A single-level action menu built on Popover. select(value, item) emits only for an enabled action, then requests closure with reason select. String and numeric identities stay distinct. Web supports Enter/Space, Up/Down, Home/End, single-character typeahead and Escape with return focus. Disabled actions are skipped by arrow navigation. Groups are visual headings; separators are not actions. Native uses accessible Mavis buttons in an anchored layer. No submenu, checkbox/radio action state, or async transaction ownership is implied; keep long tasks and confirmations in the application.
Motion
The menu grows out of its trigger like Popover, and its actions arrive one after another from the trigger's side, a few pixels each, so a long menu never waits for its tail. A chosen action bumps once and the menu holds for about a seventh of a second before it closes, long enough to see what was picked. select still fires immediately; only update:open and close wait. Reduced motion closes at once. Focus, typeahead and arrow keys work while the actions are still arriving.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const t = (en: string, br: string) => (pt.value ? br : en)
import type { ChoiceValue, MenuItem } from '@getcortexlabs/mavis-core'
const open = ref(false)
const selected = ref<ChoiceValue | null>(null)
const items = computed<MenuItem[]>(() => [
{ type: 'group', key: 'collection', label: t('Collection', 'Coleção') },
{ value: 'edit', label: t('Edit collection', 'Editar coleção'), icon: 'pencil' },
{ value: 'duplicate', label: t('Duplicate', 'Duplicar'), icon: 'copy' },
{ value: 'share', label: t('Share', 'Compartilhar'), icon: 'share', disabled: true },
{ type: 'separator', key: 'danger' },
{ value: 'remove', label: t('Remove', 'Remover'), icon: 'trash', destructive: true },
])
</script>
<template>
<MColumn gap="md">
<MMenu
v-model:open="open"
:label="t('Collection actions', 'Ações da coleção')"
:triggerLabel="t('Actions', 'Ações')"
icon="ellipsis"
:items="items"
@select="(value) => (selected = value)"
/>
<MText
id="menu-selection"
:text="String(selected ?? t('Choose an action.', 'Escolha uma ação.'))"
tone="muted"
/>
</MColumn>
</template>Desktop
MMenu opens below its trigger, or at the pointer on a secondary click, and moves with the arrow keys, Home, End and the first letters of an item; Enter chooses and Tab leaves, the same on the Mac and on Windows. Items have no shortcut field in the contract, so none is shown. See Desktop components.