SpeedDial
Included in RC.12
Available in Mavis 0.1.0-rc.12 for Vue + Vite, Nuxt and NativeScript. Keep the Mavis packages at the same version.
<MSpeedDial
v-model:open="open"
label="Create something"
:actions="actions"
@select="handleAction"
/>| Prop | Type | Default | Contract |
|---|---|---|---|
material | solid / glass | theme | Sets the material for this component. See Bar and speed dial material. |
label / actions | string / SpeedDialAction[] | required | Visible trigger and named actions. |
open | boolean | false | Controlled via v-model:open. |
direction | up or down | up | Preferred opening direction. |
disabled / icon / closeLabel | boolean / IconName / string | false / plus / Close actions | Trigger availability, artwork and explicit close action. |
A controlled quick-action launcher using the existing Popover lifecycle. Actions have unique value, label, optional icon and disabled. Selection emits select(value, action) and requests closing. The application owns the action itself. Jolt animates the panel and sequential action entry; keyboard and focus behavior remain with Popover. Escape, outside dismissal and native back preserve the existing overlay rules. Direction chooses upward/downward preferred placement; Web fits the viewport. Native presentation uses the existing popover layer.
Actions fan out from the trigger: the one nearest the trigger arrives first and each next one travels a little further with a spring. The first action, which receives focus when the panel opens, only fades in so the focused control never moves.
<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)
const open = ref(false),
selected = ref(''),
down = ref(false)
const actions = computed(() => [
{ value: 'note', label: t('Write a note', 'Escrever uma nota'), icon: 'pencil' as const },
{ value: 'photo', label: t('Add a photo', 'Adicionar uma foto'), icon: 'image' as const },
{ value: 'invite', label: t('Invite someone', 'Convidar alguém'), icon: 'users' as const },
{ value: 'publish', label: t('Publish', 'Publicar'), icon: 'send' as const, disabled: true },
])
</script>
<template>
<MColumn gap="lg">
<MText text="MAKE SOMETHING / TOGETHER" variant="overline" tone="primary" />
<MText
:text="t('A small action. A new possibility.', 'Uma pequena ação. Uma nova possibilidade.')"
variant="title"
/>
<MCard gap="lg" padding="lg"
><MText
:text="
t('Your next chapter is still unwritten.', 'Seu próximo capítulo ainda está em branco.')
"
tone="muted" /><MBox :height="80" /><MRow justify="end"
><MSpeedDial
v-model:open="open"
:label="t('Create something', 'Criar algo')"
:closeLabel="t('Close actions', 'Fechar ações')"
:actions="actions"
:direction="down ? 'down' : 'up'"
@select="(value) => (selected = String(value))" /></MRow
></MCard>
<MSwitch v-model="down" :label="t('Open downward', 'Abrir para baixo')" />
<MText id="dial-selection" :text="selected || '—'" variant="caption" tone="muted" />
</MColumn>
</template>Opening or closing the dial turns the trigger glyph into its next state. The trigger keeps its accessible name and expanded state during the change. On iOS and Android, the panel aligns with the visible trigger even when its containing row spans the screen.
Desktop
MSpeedDial is a primary button that opens a menu of its actions inside the window, the same on the Mac and on Windows, with the keyboard of a menu. direction places the menu below or above the button. See Desktop components.