Đến nội dung chính

Thông báo nổi

Dùng để xác nhận ngắn rằng việc vừa làm đã xong, và bỏ lỡ cũng không mất gì.

Phản hồi

Xem trước trực tiếp

Nguồn

<div class="dc-toastzone">
  <div class="dc-toast" role="status">
    <svg class="dc-toast__icon dc-toast__icon--ok" viewBox="0 0 20 20" aria-hidden="true" focusable="false"><path d="M10 1.6a8.4 8.4 0 1 0 0 16.8 8.4 8.4 0 0 0 0-16.8Zm4.3 6.5-5.1 5.2a1 1 0 0 1-1.4 0L5.7 11a1 1 0 0 1 1.4-1.4l1.4 1.5 4.4-4.4a1 1 0 0 1 1.4 1.4Z"/></svg>
    <p class="dc-toast__text">임시 저장했습니다</p>
    <button class="dc-toast__close" type="button"><svg viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M4.2 4.2l7.6 7.6M11.8 4.2l-7.6 7.6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg><span class="dc-sr">알림 닫기</span></button>
  </div>
</div>
.dc-toastzone {
  display: flex; align-items: flex-end; justify-content: flex-end;
  min-height: 104px; padding: var(--dc-3);
  border: 1px dashed var(--dc-line);
  border-radius: var(--dc-r-md);
  background: var(--dc-sunken);
}
.dc-toast {
  display: flex; align-items: center; gap: var(--dc-3);
  max-width: 380px;
  padding: var(--dc-3) var(--dc-3) var(--dc-3) var(--dc-4);
  border: 1px solid var(--dc-line-bold);
  border-radius: var(--dc-r-md);
  background: var(--dc-surface);
  box-shadow: var(--dc-sh-3);
  font-family: var(--dc-font);
}
.dc-toast__icon { flex: none; width: 20px; height: 20px; fill: currentColor; }
.dc-toast__icon--ok { color: var(--dc-ok); }
.dc-toast__icon--bad { color: var(--dc-danger); }
.dc-toast__text { flex: 1 1 auto; margin: 0; font-size: 14px; line-height: 1.5; color: var(--dc-text); }
.dc-toast__action {
  flex: none; min-height: 32px; padding: 0 var(--dc-2);
  border: 0; border-radius: var(--dc-r-xs);
  background: transparent; color: var(--dc-brand-text);
  font-size: 14px; font-weight: 700;
  transition: background var(--dc-fast);
}
.dc-toast__action:hover { background: var(--dc-brand-soft); }
.dc-toast__close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--dc-r-sm);
  background: transparent; color: var(--dc-text-mute);
  transition: background var(--dc-fast), color var(--dc-fast);
}
.dc-toast__close svg { width: 16px; height: 16px; }
.dc-toast__close:hover { background: color-mix(in srgb, var(--dc-text) 8%, transparent); color: var(--dc-text); }
.dc-toast--bad { border-color: color-mix(in srgb, var(--dc-danger) 45%, transparent); }
@media (max-width: 440px) {
  .dc-toast { max-width: none; width: 100%; }
}

Cách dùng

  • Chỉ đặt vào đó điều có thể bỏ lỡ — điều buộc phải đọc thì dùng biểu ngữ hoặc hộp thoại
  • Việc xoá phải kèm nút hoàn tác; nếu không hoàn tác được thì đừng thông báo kiểu này
  • Mỗi lần một cái — đừng xếp chồng, giữ cái mới nhất

Điểm cần lưu ý

  • Chữ mất sau năm giây coi như không tồn tại với người đọc chậm — toast có hoàn tác thì để lâu hơn
  • Khung nét đứt trong bản xem trước chỉ mô phỏng góc dưới phải; thực tế dùng position: fixed

Tiếp theo