Alert
MAlert places a message in the screen's normal layout. Use it for context that should remain available while the person decides what to do next.
Next alpha
Available in 0.1.0-alpha.4.
Usage
<m-alert
v-if="visible"
title="Download failed"
description="Check your connection and try again."
tone="error"
dismissible
closeLabel="Dismiss download notice"
@close="visible = false"
>
<template #actions><m-button @click="retry">Try again</m-button></template>
</m-alert>visible and retry belong to the app. Closing emits a request; the alert stays mounted until the app removes it.
Props
| Prop | Type | Default | Behavior |
|---|---|---|---|
title | string | required | Nonempty message title. |
description | string | empty | Optional supporting text. |
tone | info | success | warning | error | info | Semantic icon and border color. |
dismissible | boolean | false | Shows the close button. |
closeLabel | string | Dismiss message | Accessible close-button name; translate in the app. Must be nonempty when dismissible. |
announce | boolean | false | Opts into announcements for dynamic messages, without moving focus. |
open | boolean | — | Controlled presence for v-model:open. false collapses and fades the notice before it leaves the layout. Without it, v-if keeps working as before. |
width / grow / shrink | dimension / number / number | auto / 0 / context | Layout participation, as in Column. |
id / accessibilityHidden | string / boolean | — / false | Optional identifier and accessibility exclusion. |
Empty titles or required close labels throw TypeError. Text wraps naturally; actions sit below the message in a wrapping Row. There is no fixed height.
Actions and dismissal
The named actions slot accepts app-owned controls. The close button emits close with no payload and remains separate from these controls. There is no default slot, timeout, queue, overlay, entrance animation or focus trap. Toast provides transient feedback; Dialog requests a modal decision.
Info uses the theme accent; success, warning and error use their semantic colors. Icons are decorative. Write a title that communicates the state without relying on color alone.
Announcements
Static notices default to announce=false. Enable it for newly inserted or updated results when speaking the message is useful. Web uses a status region, or alert for the error tone, around the title and description; actions stay outside this region. Initial-page announcement behavior varies by browser and screen reader.
On native, title and description form one accessible group and the action buttons remain individually accessible. When loaded, announce=true requests a platform announcement for new message text; repeated identical text on a retained page is not announced again. Pending work is cleared on unload/unmount. Actual speech and interruption depend on the active screen reader; changing the tone alone does not repeat the native announcement. Alert never moves focus or manages app navigation.
Library uses alerts for cancelled, failed and completed downloads, with retry and open-saved actions.
Motion
The tone icon pops in when the notice appears and bumps when its title or tone changes; an error shakes once instead. The dismiss button emits update:open with false before close, so v-model:open lets the notice collapse smoothly. Text and announcements are never delayed.
Full example
View source
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { computed, ref } from 'vue'
import type { AlertTone } from '@getcortexlabs/mavis-core'
const { t, locale } = useCatalogLocale(() => props.lang)
const props = withDefaults(defineProps<{ lang?: 'en' | 'pt' }>(), { lang: undefined })
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const tone = ref<AlertTone>('info')
const visible = ref(true)
const announce = ref(false)
const actions = ref(0)
const options = computed(
() =>
[
{ value: 'info', label: pt.value ? 'Informação' : 'Information' },
{ value: 'success', label: pt.value ? 'Sucesso' : 'Success' },
{ value: 'warning', label: pt.value ? 'Atenção' : 'Warning' },
{ value: 'error', label: pt.value ? 'Erro' : 'Error' },
] as const,
)
function selectTone(value: AlertTone) {
tone.value = value
visible.value = true
}
const messages = computed(() =>
pt.value
? {
info: {
title: 'Suas leituras vão com você.',
description: 'Prepare uma coleção para os momentos em que a conexão fica para depois.',
},
success: {
title: 'Tudo pronto para continuar.',
description: 'As alterações foram salvas. Você pode seguir de onde parou.',
},
warning: {
title: 'Um detalhe antes de sair.',
description:
'Há alterações que ainda não foram salvas. Revise os detalhes para não perder seu trabalho.',
},
error: {
title: 'Não foi possível concluir.',
description:
'A conexão foi interrompida. Seus dados continuam aqui; tente novamente quando estiver pronto.',
},
}
: {
info: {
title: 'Your readings go with you.',
description: 'Prepare a collection for moments when the connection can wait.',
},
success: {
title: 'Ready to carry on.',
description: 'Your changes are saved. Pick up where you left off.',
},
warning: {
title: 'One detail before you leave.',
description: 'Some changes have not been saved. Review the details to keep your work.',
},
error: {
title: 'Could not finish.',
description:
'The connection was interrupted. Your data is still here; try again when you are ready.',
},
},
)
</script>
<template>
<m-column gap="lg" id="alert-demo">
<m-column gap="sm">
<m-text variant="overline" tone="accent">{{
t(pt ? 'CLAREZA, NO CONTEXTO' : 'CLARITY, IN CONTEXT')
}}</m-text>
<m-text variant="title">{{
t(pt ? 'A mensagem certa. No lugar certo.' : 'The right message. In the right place.')
}}</m-text>
<m-text tone="muted">{{
t(
pt
? 'Um aviso acompanha a tarefa sem tirar você dela.'
: 'A notice follows the task without taking you away from it.',
)
}}</m-text>
</m-column>
<m-row gap="sm" wrap>
<m-button
v-for="option in options"
:key="option.value"
size="sm"
:variant="tone === option.value ? 'primary' : 'secondary'"
@click="selectTone(option.value)"
>{{ t(option.label) }}</m-button
>
</m-row>
<m-alert
v-model:open="visible"
id="alert-example"
v-bind="messages[tone]"
:tone="tone"
dismissible
:closeLabel="t(pt ? 'Fechar aviso' : 'Dismiss notice')"
:announce="announce"
>
<template #actions>
<m-button size="sm" variant="secondary" @click="actions++">{{
t(pt ? 'Ver detalhes' : 'View details')
}}</m-button>
</template>
</m-alert>
<m-button v-if="!visible" variant="secondary" @click="visible = true">{{
t(pt ? 'Mostrar aviso' : 'Show notice')
}}</m-button>
<m-text variant="caption" tone="muted">{{
t(
actions
? pt
? `Detalhes abertos ${actions} vez(es).`
: `Details opened ${actions} time(s).`
: pt
? 'A ação e o fechamento são controlados por esta tela.'
: 'This screen controls actions and dismissal.',
)
}}</m-text>
<m-switch
v-model="announce"
:label="t(pt ? 'Anunciar atualizações' : 'Announce updates')"
:helperText="
t(
pt
? 'Ative para avisar leitores de tela sobre uma mensagem nova.'
: 'Enable to notify screen readers about a new message.',
)
"
/>
<m-alert
:title="t(pt ? 'Sem pressa para desaparecer.' : 'No rush to disappear.')"
:description="
t(
pt
? 'Este aviso permanece no conteúdo, sem temporizador e sem botão de fechar.'
: 'This notice stays in the content, with no timeout or close button.',
)
"
tone="info"
/>
</m-column>
</template>