Feedback e status

VAlert

Componentev-model9 exemplos11 propsA2UI · Alert

Mensagem **dentro do conteúdo** (formulário, card, seção): ocupa a largura do container, com ícone na cor da variante, fundo suave e borda leve. Cinco variantes semânticas, três tamanhos, fechamento opcional e uma transição curta.

Importação
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

Uso

Exemplo
<script setup lang="ts">

</script>

<template>
  
</template>

Playground

Os controles abaixo são gerados a partir das props declaradas em VAlert.types.ts; o código acompanha cada mudança.

Exemplos

Variantes, tamanhos e estados, extraídos das stories da biblioteca.

Default

Mensagem dentro do conteúdo (formulário, card, seção): ocupa a largura do container, ícone na cor da variante e fundo suave. Para um aviso da página inteira use o VBanner.

Ver código
vue
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

<template>
  <VAlert
    v-model="value"
    title="New update available"
    description="Version 2.4 includes performance improvements and bug fixes."
    dismissible />
</template>

Variants

info, success, warning, danger e neutral. Título curto e, quando precisa, uma descrição.

Ver código
vue
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

<template>
  <div style="display:grid;gap:12px">
    <VAlert variant="info" title="New update available" description="Version 2.4 includes performance improvements." />
    <VAlert variant="success" title="Changes saved" description="Your profile is up to date." />
    <VAlert variant="warning" title="Your trial ends in 3 days" description="Add a payment method to keep your projects." />
    <VAlert variant="danger" title="Payment failed" description="We couldn't charge the card ending in 4242." />
    <VAlert variant="neutral" title="Read-only workspace" description="Ask an owner for edit access." />
  </div>
</template>

Sizes

sm (12px, compacto), md (14px, padrão) e lg (mais respiro).

Ver código
vue
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

<template>
  <div style="display:grid;gap:12px">
    <VAlert size="sm" title="Small alert" description="Compact density for dense forms and tables." dismissible />
    <VAlert size="md" title="Medium alert" description="Default density for most content." dismissible />
    <VAlert size="lg" title="Large alert" description="More room for prominent, page-section messages." dismissible />
  </div>
</template>

Title Only

Só o título, para mensagens de uma linha.

Ver código
vue
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

<template>
  <VAlert
    v-model="value"
    variant="success"
    title="Your changes have been saved."
    dismissible />
</template>

With Action

Slot #action com um VButton pequeno, alinhado ao centro do alerta.

Ver código
vue
<script setup lang="ts">
import { VAlert, VButton } from 'vueui-nova-kit'

const args = {
  variant: 'info',
  size: 'md',
  title: 'New update available',
  description: 'Version 2.4 includes performance improvements and bug fixes.',
  dismissible: true
}
</script>

<template>
  <VAlert v-bind="args" variant="warning" title="Your trial ends in 3 days" description="Add a payment method to keep your projects.">
    <template #action><VButton size="sm" variant="outline">Add payment</VButton></template>
  </VAlert>
</template>

Custom Icon

Slot #icon para trocar o ícone padrão da variante.

Ver código
vue
<script setup lang="ts">
import { VAlert, VIcon } from 'vueui-nova-kit'

const args = {
  variant: 'info',
  size: 'md',
  title: 'New update available',
  description: 'Version 2.4 includes performance improvements and bug fixes.',
  dismissible: true
}
const sparklesIcon = {
  width: 24,
  height: 24,
  body: '<path fill=\'none\' stroke=\'currentColor\' stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'2\' d=\'M15.4651 9.1794L16.7409 12.4141C16.8933 12.8006 17.1994 13.1067 17.5859 13.2591L20.8206 14.5349C21.0117 14.6102 21.1372 14.7947 21.1372 15C21.1372 15.2053 21.0117 15.3898 20.8206 15.4651L17.5859 16.7409C17.1994 16.8933 16.8933 17.1994 16.7409 17.5859L15.4651 20.8206C15.3898 21.0117 15.2053 21.1372 15 21.1372C14.7947 21.1372 14.6102 21.0117 14.5349 20.8206L13.2591 17.5859C13.1067 17.1994 12.8006 16.8933 12.4141 16.7409L9.1794 15.4651C8.9883 15.3898 8.8628 15.2053 8.8628 15C8.8628 14.7947 8.9883 14.6102 9.1794 14.5349L12.4141 13.2591C12.8006 13.1067 13.1067 12.8006 13.2591 12.4141L14.5349 9.1794C14.6102 8.9883 14.7947 8.8628 15 8.8628C15.2053 8.8628 15.3898 8.9883 15.4651 9.1794ZM6.7151 3.1794L7.2131 4.4419C7.3655 4.8285 7.6715 5.1345 8.0581 5.2869L9.3206 5.7849C9.5117 5.8602 9.6372 6.0447 9.6372 6.25C9.6372 6.4553 9.5117 6.6398 9.3206 6.7151L8.0581 7.2131C7.6715 7.3655 7.3655 7.6715 7.2131 8.0581L6.7151 9.3206C6.6398 9.5117 6.4553 9.6372 6.25 9.6372C6.0447 9.6372 5.8602 9.5117 5.7849 9.3206L5.2869 8.0581C5.1345 7.6715 4.8285 7.3655 4.4419 7.2131L3.1794 6.7151C2.9883 6.6398 2.8628 6.4553 2.8628 6.25C2.8628 6.0447 2.9883 5.8602 3.1794 5.7849L4.4419 5.2869C4.8285 5.1345 5.1345 4.8285 5.2869 4.4419L5.7849 3.1794C5.8602 2.9883 6.0447 2.8628 6.25 2.8628C6.4553 2.8628 6.6398 2.9883 6.7151 3.1794Z\'/>'
}
</script>

<template>
  <VAlert v-bind="args" title="AI summaries are on" description="New threads get a summary automatically.">
    <template #icon><VIcon :icon="sparklesIcon" size="sm" /></template>
  </VAlert>
</template>

Loading

loading=true: o ícone vira um indicador de progresso.

Ver código
vue
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

<template>
  <VAlert
    v-model="value"
    title="Syncing your workspace"
    description="This usually takes a few seconds."
    dismissible
    loading />
</template>

Disabled

disabled=true.

Ver código
vue
<script setup lang="ts">
import { VAlert } from 'vueui-nova-kit'
</script>

<template>
  <VAlert
    v-model="value"
    title="New update available"
    description="Version 2.4 includes performance improvements and bug fixes."
    dismissible
    disabled />
</template>

Controlled VModel

Visibilidade controlada com v-model: fechar o alerta atualiza o ref; o botão o reabre.

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VAlert, VButton } from 'vueui-nova-kit'

const open = ref(true)
</script>

<template>
  <div style="display:grid;gap:12px;justify-items:start">
    <VAlert v-model="open" dismissible title="Controlled alert" description="Dismiss it and bring it back with the button." />
    <VButton v-if="!open" size="sm" variant="outline" @click="open = true">Show alert again</VButton>
  </div>
</template>

Acessibilidade

The root uses semantic role="alert" and aria-atomic="true". The close control is a native button with an accessible label and supports Tab, Enter, and Space through native button behavior. Disabled and loading states expose aria-disabled/aria-busy, and the component uses icon plus text rather than color alone.

Motion

TriggerPropertyDurationEasing
Close / enteropacity, transform--v-motion-normal--v-ease-in
Close button hoverbackground--v-motion-normal--v-ease-out
Close button presstransform--v-motion-press--v-ease-out
Loadingtransform--v-motion-spin-durationlinear

prefers-reduced-motion: reduce removes transitions, transforms, and the loading animation.

Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.

Props

PropTipoDefaultDescrição
modelValuebooleanundefinedControls visibility when supplied. Without it, the alert is internally dismissible.
titlestring——
descriptionstring——
disabledbooleanfalse—
loadingbooleanfalse—
dismissiblebooleanfalse—
sizeVAlertSize"md"—
variantVAlertVariant"info"—
layoutdeprecatedVAlertLayout"inline"—
ariaLabelstring——
dismissLabelstring——

Events

EventoPayloadDescrição
@dismiss——
@update:modelValuevalue: boolean—

Slots

SlotProps do slot
#icon—
#title—
#description—
#default—
#action—

Fonte: src/components/feedback/VAlert/VAlert.vue · tipos: src/components/feedback/VAlert/VAlert.types.ts