feedback · alerte

Alerte / Information

Bandeaux d'alerte inline (information et avertissement), avec bouton de fermeture fonctionnel.

Voir le code source
<style>
.bn-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  max-width: 460px;
  padding: 2rem;
  font-family: 'Inter', sans-serif;
  background: #0B0F10;
}

.bn-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;

  padding: 0.9rem 1rem;
  border-radius: 8px;
  border: 1px solid;
  transition: opacity 0.25s ease;
}

.bn-alert.is-closing {
  opacity: 0;
}

.bn-alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
}

.bn-alert__text {
  flex: 1;
  margin: 0;
  color: #C7C1B7;
  font-size: 0.85rem;
  line-height: 1.5;
}

.bn-alert__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #5C6160;
  cursor: pointer;
  font-size: 0.7rem;
}

.bn-alert--info {
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.05);
}

.bn-alert--info .bn-alert__icon {
  background: rgba(96, 165, 250, 0.15);
  color: #60A5FA;
}

.bn-alert--warning {
  border-color: rgba(245, 197, 24, 0.3);
  background: rgba(245, 197, 24, 0.05);
}

.bn-alert--warning .bn-alert__icon {
  background: rgba(245, 197, 24, 0.15);
  color: #F5C518;
}

</style>

<div class="bn-alerts" data-fx-root>
  <div class="bn-alert bn-alert--info">
    <span class="bn-alert__icon">i</span>
    <p class="bn-alert__text">Cette action est irréversible. Veuillez vérifier avant de continuer.</p>
    <button type="button" class="bn-alert__close" aria-label="Fermer">✕</button>
  </div>

  <div class="bn-alert bn-alert--warning">
    <span class="bn-alert__icon">!</span>
    <p class="bn-alert__text">Certaines modifications peuvent affecter d'autres éléments.</p>
    <button type="button" class="bn-alert__close" aria-label="Fermer">✕</button>
  </div>
</div>


<script>
(function () {
  const root = document.querySelector('.bn-alerts[data-fx-root]');
  if (!root) return;

  root.querySelectorAll('.bn-alert__close').forEach((btn) => {
    btn.addEventListener('click', () => {
      const alertEl = btn.closest('.bn-alert');
      alertEl.classList.add('is-closing');
      alertEl.addEventListener('transitionend', () => alertEl.remove(), { once: true });
    });
  });
})();

</script>