Use toasts for brief, non-blocking notifications. They should auto-dismiss after 3-5 seconds for success messages, but persist for errors until the user dismisses them.
Dismissible
Toasts with a close button for manual dismissal — essential for error messages users need to read.
Action buttons in toasts should use outline or ghost styling to avoid competing visually with the main content area. Keep the button text short — "Undo", "Retry", "View" — not full sentences.
Positions
Toast placement in different corners and edges — choose the position that least disrupts the user flow.
toast-positions
Live
untitled.html
HTML
1
<div class="grid">
2
<div class="pos top-left">
3
<div class="toast info mini">
4
Top Left
5
</div>
6
</div>
7
<div class="pos top-right">
8
<div class="toast info mini">
9
Top Right
10
</div>
11
</div>
12
<div class="pos bottom-left">
13
<div class="toast info mini">
14
Bottom Left
15
</div>
16
</div>
17
<div class="pos bottom-right">
18
<div class="toast info mini">
19
Bottom Right
20
</div>
21
</div>
22
<div class="pos top-center">
23
<div class="toast info mini">
24
Top Center
25
</div>
26
</div>
27
</div>
untitled.css
CSS
1
* {
2
margin:0;
3
padding:0;
4
box-sizing:border-box
5
}
6
body {
7
font-family:system-ui,
8
sans-serif;
9
background:#0D0D0D;
10
padding:24px
11
}
12
.grid {
13
position:relative;
14
width:100%;
15
height:260px;
16
border:1px dashed #2A2A3E;
17
border-radius:8px;
18
margin:16px auto
19
}
20
.pos {
21
position:absolute
22
}
23
.pos.top-left {
24
top:12px;
25
left:12px
26
}
27
.pos.top-right {
28
top:12px;
29
right:12px
30
}
31
.pos.bottom-left {
32
bottom:12px;
33
left:12px
34
}
35
.pos.bottom-right {
36
bottom:12px;
37
right:12px
38
}
39
.pos.top-center {
40
top:12px;
41
left:50%;
42
transform:translateX(-50%)
43
}
44
.toast {
45
padding:10px 16px;
46
border-radius:8px;
47
font-size:11px;
48
font-weight:600;
49
animation:fadeIn .3s ease;
50
white-space:nowrap
51
}
52
.toast.mini {
53
background:#0A0F1A;
54
border:1px solid rgba(59,
55
130,
56
246,
57
.25);
58
color:#3B82F6
59
}
60
@keyframes fadeIn {
61
from {
62
opacity:0;
63
transform:translateY(-8px)
64
}
65
to {
66
opacity:1;
67
transform:translateY(0)
68
}
69
}
preview
⚠
warning
Position toasts away from primary navigation areas. Bottom-right is the most common default. Avoid top-center for long messages as it can overlap with the browser toolbar on mobile.
A shrinking progress bar at the top of the toast visually communicates how long it will stay visible. Animate the width from 100% to 0% over the auto-dismiss duration. For persistent toasts (errors), omit the progress bar entirely.
Rich Toast
Toasts with avatars, images, and complex layouts for richer notification content.
toast-rich
Live
untitled.html
HTML
1
<div class="wrap">
2
<div class="toast rich">
3
<div class="t-avatar" style="background:#3B82F6">
4
JD
5
</div>
6
<div class="content">
7
<strong>
8
Jane commented on your post
9
</strong>
10
<p>
11
"Great article! The section on caching was really helpful."
12
</p>
13
</div>
14
</div>
15
<div class="toast rich">
16
<div class="t-avatar" style="background:#A855F7">
17
AB
18
</div>
19
<div class="content">
20
<strong>
21
Alex shared a file
22
</strong>
23
<p>
24
design-system-v2.fig
25
</p>
26
</div>
27
<button class="toast-btn">
28
View
29
</button>
30
</div>
31
</div>
untitled.css
CSS
1
* {
2
margin:0;
3
padding:0;
4
box-sizing:border-box
5
}
6
body {
7
font-family:system-ui,
8
sans-serif;
9
background:#0D0D0D;
10
padding:24px
11
}
12
.wrap {
13
max-width:380px;
14
margin:0 auto;
15
display:flex;
16
flex-direction:column;
17
gap:10px
18
}
19
.toast {
20
display:flex;
21
align-items:flex-start;
22
gap:10px;
23
padding:14px 16px;
24
border-radius:10px;
25
font-size:12px;
26
line-height:1.4;
27
background:#0A0A0F;
28
border:1px solid #1A1A2E;
29
color:#E0E0E0;
30
animation:slideIn .3s ease
31
}
32
.t-avatar {
33
width:36px;
34
height:36px;
35
border-radius:50%;
36
display:flex;
37
align-items:center;
38
justify-content:center;
39
font-size:13px;
40
font-weight:700;
41
color:#fff;
42
flex-shrink:0
43
}
44
.content {
45
flex:1
46
}
47
.content strong {
48
display:block;
49
margin-bottom:2px;
50
font-size:12px
51
}
52
.content p {
53
margin:0;
54
opacity:.6;
55
font-size:11px;
56
line-height:1.4
57
}
58
.toast-btn {
59
padding:6px 14px;
60
border-radius:6px;
61
font-size:11px;
62
font-weight:600;
63
cursor:pointer;
64
border:1px solid #2A2A3E;
65
background:transparent;
66
color:#A0A0A0;
67
flex-shrink:0;
68
transition:all .2s
69
}
70
.toast-btn:hover {
71
border-color:#3B82F6;
72
color:#3B82F6
73
}
74
@keyframes slideIn {
75
from {
76
opacity:0;
77
transform:translateX(20px)
78
}
79
to {
80
opacity:1;
81
transform:translateX(0)
82
}
83
}
preview
Minimal Style
Clean, minimal toasts with just an icon, text, and close button — no heavy backgrounds or borders.
Minimal toasts work well in developer tools and power-user interfaces where visual noise should be low. For consumer-facing apps, the richer variants with titles and descriptions are usually more appropriate.