រំលងទៅខ្លឹមសារ

សារលោត

ប្រើសម្រាប់ការបញ្ជាក់ខ្លីថាការដែលទើបធ្វើបានសម្រេច ហើយបើខកខានអានក៏មិនបាត់បង់អ្វី។

មតិត្រឡប់

មើលជាមុនផ្ទាល់

ប្រភព

<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%; }
}

របៀបប្រើ

  • ដាក់តែអ្វីដែលអាចខកខានបាន — អ្វីដែលត្រូវអានឲ្យប្រាកដ ត្រូវដាក់ក្នុងផ្ទាំង ឬប្រអប់សន្ទនា
  • ការលុបត្រូវមានប៊ូតុងត្រឡប់ក្រោយជាប់; បើត្រឡប់មិនបាន មិនត្រូវប្រាប់តាមសារលោត
  • មួយម្ដងមួយ — មិនត្រូវដាក់ជង់, ទុកតែចុងក្រោយ

ចំណុចត្រូវប្រុងប្រយ័ត្ន

  • អក្សរដែលបាត់ក្នុងប្រាំវិនាទី ដូចគ្មានសម្រាប់អ្នកអានយឺត — បើមានប៊ូតុងត្រឡប់ ត្រូវទុកយូរជាង
  • ប្រអប់បន្ទាត់ដាច់ៗក្នុងការមើលជាមុន ធ្វើត្រាប់ជ្រុងខាងក្រោមស្ដាំ; ការប្រើពិតគឺ position: fixed

បន្ទាប់