# Alerta: info, éxito, aviso y peligro

> Alerta de iVOLT: mensajes de información, éxito, aviso y peligro con título, cuerpo y acciones, usando role=status o role=alert. Solo CSS.

Source: https://ivolt.intervolutions.com/es/components/alert · iVOLT 1.1.2 · Español

Un mensaje que el usuario debería notar. Usa `role="status"` para los mensajes informativos o de éxito y `role="alert"` solo para los urgentes que deben anunciarse de inmediato. Sin JavaScript: para descartarlo, elimina el nodo.

**CSS:** `css/components/alert.css` (dentro de `ivolt.css`).

No se ha podido cargar la demo. [Abrir sola](https://ivolt.intervolutions.com/stage/alert/variants.html?id=fx-alert-variants)

```html
<div class="iv-stack iv-u-gap-4">
  <div class="iv-alert iv-alert--info" role="status">
    <span class="iv-alert__icon" aria-hidden="true">
      <svg viewBox="0 0 20 20" fill="currentColor"><circle cx="10" cy="10" r="9" fill="none" stroke="currentColor" stroke-width="2"/><rect x="9" y="8.5" width="2" height="6" rx="1"/><circle cx="10" cy="5.75" r="1.25"/></svg>
    </span>
    <p class="iv-alert__title">Scheduled maintenance</p>
    <div class="iv-alert__body">
      <p>The build service is read-only on Sunday between 02:00 and 04:00 UTC.</p>
    </div>
  </div>

  <div class="iv-alert iv-alert--success" role="status">
    <span class="iv-alert__icon" aria-hidden="true">
      <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2"><circle cx="10" cy="10" r="9"/><path d="M6 10.5 9 13.5 14.5 7" stroke-linecap="round" stroke-linejoin="round"/></svg>
    </span>
    <p class="iv-alert__title">Settings saved</p>
    <div class="iv-alert__body">
      <p>Your notification preferences now apply to every project in this workspace.</p>
    </div>
  </div>

  <div class="iv-alert iv-alert--warning" role="status">
    <span class="iv-alert__icon" aria-hidden="true">
      <svg viewBox="0 0 20 20" fill="currentColor"><path d="M10 1.5 19 17.5H1z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round"/><rect x="9" y="7" width="2" height="6" rx="1"/><circle cx="10" cy="15" r="1.1"/></svg>
    </span>
    <p class="iv-alert__title">Warning: token expires in three days</p>
    <div class="iv-alert__body">
      <p>Deployments will stop once the access token expires. Rotate it from the project settings.</p>
    </div>
    <div class="iv-alert__actions">
      <button class="iv-button iv-button--secondary iv-button--sm" type="button">Rotate token</button>
      <button class="iv-button iv-button--ghost iv-button--sm" type="button">Remind me later</button>
    </div>
  </div>

  <div class="iv-alert iv-alert--danger" role="alert">
    <span class="iv-alert__icon" aria-hidden="true">
      <svg viewBox="0 0 20 20" fill="currentColor"><circle cx="10" cy="10" r="9" fill="none" stroke="currentColor" stroke-width="2"/><rect x="9" y="5" width="2" height="7" rx="1"/><circle cx="10" cy="14.5" r="1.1"/></svg>
    </span>
    <p class="iv-alert__title">Error: the file could not be uploaded</p>
    <div class="iv-alert__body">
      <p>The archive exceeds the 25 MB limit. Split it or upload the files individually.</p>
    </div>
    <div class="iv-alert__actions">
      <button class="iv-button iv-button--danger iv-button--sm" type="button">Try again</button>
    </div>
  </div>

  <div class="iv-alert" role="status">
    <p class="iv-alert__title">Without an icon</p>
    <div class="iv-alert__body">
      <p>The icon is optional and always decorative; the severity is stated in the text.</p>
    </div>
  </div>
</div>
```

## Anatomía

`iv-alert` (`--info` por defecto, `--success --warning --danger`) con `iv-alert__icon` opcional (`aria-hidden`), `iv-alert__title`, `iv-alert__body` y `iv-alert__actions`.

## Errores frecuentes

- `role="alert"` en todos los mensajes: el lector de pantalla interrumpe al usuario cada vez.
- Alertas renderizadas al cargar la página para contenido que no es una alerta.

## Índice de clases

Partes y modificadores de esta familia que los ejemplos de arriba no muestran. La lista completa por hoja está en la [referencia](https://ivolt.intervolutions.com/es/reference).

| Clase | Qué hace |
| --- | --- |
| `iv-alert--success` | Tono de éxito: el icono y el filete toman el color de éxito. |
| `iv-alert--warning` | Tono de aviso. |
| `iv-alert--danger` | Tono de peligro; acompáñalo de un texto que nombre el problema, nunca solo color. |
