ComponentesComponents

AlertaAlert

Mensaje en la página: información, éxito, advertencia o error.In-page message: info, success, warning or error.

DiseñoDesign: coss ui (MIT) · alert.tsxMITambos · densidaddensity baja · sobriaMarkdownJSON

CódigoCode

<div class="c-alert-stack">
  <div class="c-alert c-alert--info" role="note">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
    <p class="c-alert__title">Hay una versión nueva</p>
    <p class="c-alert__description">Actualiza para usar el tema oscuro automático.</p>
    <div class="c-alert__action"><button class="c-btn c-btn--outline c-btn--sm" type="button">Actualizar</button></div>
  </div>
  <div class="c-alert c-alert--success" role="note">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21.801 10A10 10 0 1 1 17 3.335"/><path d="m9 11 3 3L22 4"/></svg>
    <p class="c-alert__title">Pago recibido</p>
    <p class="c-alert__description">Te enviamos el recibo a tu correo.</p>
  </div>
  <div class="c-alert c-alert--warning" role="note">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>
    <p class="c-alert__title">Tu plan vence en 3 días</p>
    <p class="c-alert__description">Renueva para no perder tus proyectos.</p>
  </div>
  <div class="c-alert c-alert--error" role="alert">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>
    <p class="c-alert__title">No se pudo guardar</p>
    <p class="c-alert__description">Revisa tu conexión e inténtalo de nuevo.</p>
  </div>
</div>

«Todo» trae tokens, dependencias y componente en un solo archivo, listo para abrir o dárselo a un agente.“All” bundles tokens, dependencies and the component in one file, ready to open or hand to an agent.

InstalaciónInstallation

  1. Agrega una vezAdd once tokens.css (colores, radios, tema oscuro).(colors, radii, dark theme).
  2. Agrega también:Also add: BotónButton.
  3. Copia los archivos:Copy the files: alert.html, alert.css.
  4. Para el tema oscuro, pon la claseFor the dark theme, add the class dark ento <html>.

Cuándo usarloWhen to use it

ÚsaloUse it

  • Para mensajes que deben quedarse a la vista.
  • For messages that must stay visible.

Mejor noAvoid

  • Para confirmaciones pasajeras: usa un aviso.
  • For passing confirmations: use a toast.

AccesibilidadAccessibility

notealert
  • role=alert solo para errores urgentes; el resto usa role=note.
  • El icono es decorativo: el título dice el tipo.
  • role=alert only for urgent errors; the rest use role=note.
  • The icon is decorative: the title states the type.

Cómo probarloHow to test it

  • El lector anuncia de inmediato solo la alerta de error.
  • The screen reader immediately announces only the error alert.

CréditosCredits