Vitral 0.2
Mensagens

Message

Uma mensagem inline com título, ação e botão de fechar, em todas as severidades.

Importação

main.ts
import { Message } from '@vitral/vue';

InfoBar

Título e mensagem dividem uma linha enquanto couberem.

Update available
Restart the app to install version 2.4.
Backup complete
1,204 files were copied to the cloud.
<script setup lang="ts">import { Message, StackPanel } from '@vitral/vue';</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%">        <Message severity="info" title="Update available">Restart the app to install version 2.4.</Message>        <Message severity="success" title="Backup complete">1,204 files were copied to the cloud.</Message>        <Message severity="warn" title="Storage almost full">You have used 92% of your 15 GB.</Message>        <Message severity="danger" title="Sync failed">The server could not be reached. Check your connection and try again.</Message>    </StackPanel></template>

Ação e fechar

O slot action recebe um botão ou link; `closable` adiciona um botão de fechar que emite `close`.

New sign-in
Someone signed in from a new device in São Paulo.
<script setup lang="ts">import { Button, Message, StackPanel } from '@vitral/vue';import { ref } from 'vue'; const shown = ref(true);const key = ref(0);</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%">        <Message v-if="shown" :key="key" severity="info" title="New sign-in" closable @close="shown = false">            Someone signed in from a new device in São Paulo.            <template #action>                <Button label="Review" size="small" severity="secondary" />            </template>        </Message>        <Button v-else label="Show it again" severity="secondary" size="small" @click="(shown = true), key++" />    </StackPanel></template>

Variantes

`outlined` e `simple`; todas as severidades funcionam com cada uma.

Drafts are kept for 30 days.
Username is available.
<script setup lang="ts">import { Message, StackPanel } from '@vitral/vue';</script> <template>    <StackPanel spacing="0.625rem" style="width: 100%">        <Message severity="secondary" variant="outlined">Drafts are kept for 30 days.</Message>        <Message severity="danger" variant="outlined" title="Invalid token">Sign in again to continue.</Message>        <Message severity="danger" variant="simple">Password must have at least 8 characters.</Message>        <Message severity="success" variant="simple" icon="check">Username is available.</Message>    </StackPanel></template>

API

Lido de packages/vue/src/components/Message/types.ts, então diz o que o componente aceita de fato.

Props

NomeTipoDescrição
severitySeverityO padrão é `'info'`. `danger` e `warn` são anunciados na hora, como alertas; o resto, educadamente.
titlestringO título da InfoBar, em negrito antes da mensagem.
iconIconPropSubstitui o ícone da severidade.
hideIconbooleanOculta o ícone.
closablebooleanMostra um botão de fechar; fechar oculta a mensagem e emite `close`.
variantMessageVariant`'subtle'` (uma faixa tingida, o padrão), `'outlined'` ou `'simple'` (só texto colorido).
lifenumberMilissegundos até ela se ocultar sozinha; a contagem pausa enquanto está com hover ou foco.

Mais pt, dt e unstyled de BaseProps; veja pass-through e modo sem estilo.

Emits

EventoPayloadDescrição
closeevent: Event—
life-end——

Slots

NomeProps do slotDescrição
default——
action—A área de ação da InfoBar: um botão ou um link ao lado da mensagem.
icon——
closeicon——