34/Interaction and state
Alert and banner
Inline messages with four tones and full-width banners. They can be dismissed and remembered.
Alerts
Nueva versión disponible
Actualiza para usar los temas de color. Ver cambios
Pago recibido
Tu plan vence en 3 días
No se pudo emitir la factura
El NIT del cliente no es válido.
HTML
<div class="flex flex-col gap-3">
<div class="cb-alert cb-alert--info" role="status"><svg class="cb-alert__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 8h.01"/></svg><div class="cb-alert__body"><p class="cb-alert__title">Nueva versión disponible</p><p class="cb-alert__text">Actualiza para usar los temas de color. <a href="#">Ver cambios</a></p></div></div>
<div class="cb-alert cb-alert--success" role="status"><svg class="cb-alert__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m8 12 3 3 5-6"/></svg><div class="cb-alert__body"><p class="cb-alert__title">Pago recibido</p></div><button class="cb-alert__close" type="button" data-cb-dismiss aria-label="Cerrar"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button></div>
<div class="cb-alert cb-alert--warning" role="status"><svg class="cb-alert__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 3 2 20h20L12 3z"/><path d="M12 10v4M12 17h.01"/></svg><div class="cb-alert__body"><p class="cb-alert__title">Tu plan vence en 3 días</p><div class="cb-alert__actions"><button class="cb-btn cb-btn--outline cb-btn--sm" type="button">Renovar</button></div></div></div>
<div class="cb-alert cb-alert--danger" role="alert"><svg class="cb-alert__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="m9 9 6 6M15 9l-6 6"/></svg><div class="cb-alert__body"><p class="cb-alert__title">No se pudo emitir la factura</p><p class="cb-alert__text">El NIT del cliente no es válido.</p></div></div>
</div>
Banner
With data-cb-dismiss-key the dismissal is remembered (in localStorage).
HTML
<div class="cb-banner" data-cb-dismiss-key="demo-banner">
<span>Cobalto 0.1 ya está disponible. <a href="#">Leer anuncio ↗</a></span>
<button class="cb-banner__close" type="button" data-cb-dismiss aria-label="Cerrar anuncio"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button>
</div>
<div class="cb-banner cb-banner--subtle">Modo de prueba activo · <a href="#">Ir a producción</a></div>
Classes and modifiers
| Class | Description |
|---|---|
.cb-alert | Alert with a border and background in the tone color. |
.cb-alert--info|success|warning|danger | Tones (default: accent). |
.cb-alert__icon, .cb-alert__title, .cb-alert__text, .cb-alert__actions, .cb-alert__close | Parts. |
.cb-banner | Full-width strip in the accent color. --subtle makes it neutral. |
.is-dismissed | Hides the dismissed element. |
data-cb-* attributes
| Attribute | Description |
|---|---|
data-cb-dismiss | Button that closes the alert or banner that contains it. |
data-cb-dismissible | Marks another container as dismissible. |
data-cb-dismiss-key="clave" | Remembers the dismissal in localStorage. |
JavaScript
| Event | When it fires |
|---|---|
cb:close | On the container before hiding it; cancelable. |
Accessibility
- Use
role="alert"only for urgent errors; for the rest,role="status". - The close button needs
aria-label.