Notification Toast
右下からスライドインするトースト通知。
HTML
<button class="toast-trigger" id="toast-btn">Show Toast</button>
<div class="toast" id="toast-el">
<div class="toast-icon">✓</div>
<div>
<div style="font-weight:600;font-size:13px">Saved</div>
<div style="color:#999;font-size:11px">Your changes have been saved.</div>
</div>
</div>
CSS
.toast-trigger {
padding: 10px 24px;
background: #1a1a1a;
color: #fff;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
font-family: inherit;
cursor: pointer;
}
.toast {
position: absolute;
bottom: 16px;
right: 16px;
display: flex;
align-items: center;
gap: 10px;
padding: 12px 16px;
background: #fff;
border: 1px solid #eee;
border-radius: 10px;
box-shadow: 0 4px 16px rgba(0,0,0,.06);
transform: translateX(120%);
opacity: 0;
transition: all .4s cubic-bezier(.16,1,.3,1);
z-index: 10;
}
.toast.show {
transform: translateX(0);
opacity: 1;
}
.toast-icon {
width: 26px;
height: 26px;
background: #f0fdf4;
color: #16a34a;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: 700;
}
JavaScript
document.getElementById('toast-btn').addEventListener('click', () => {
const toast = document.getElementById('toast-el');
toast.classList.add('show');
setTimeout(() => toast.classList.remove('show'), 2500);
});