Notification Card
Compact notification with icon, title, message, timestamp, and dismiss button.
New comment
Sara replied to your post about grid layouts.
2 min ago
<div class="w-full max-w-sm rounded-2xl border border-neutral-200 bg-white p-4 shadow-sm dark:border-neutral-700 dark:bg-neutral-900">
<div class="flex items-start gap-3">
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-indigo-100 text-indigo-600 dark:bg-indigo-500/20 dark:text-indigo-300">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2a2 2 0 01-.6 1.4L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"></path>
</svg>
</div>
<div class="min-w-0 flex-1">
<p class="text-sm font-semibold text-neutral-900 dark:text-white">New comment</p>
<p class="mt-0.5 truncate text-sm text-neutral-500 dark:text-neutral-400">Sara replied to your post about grid layouts.</p>
<p class="mt-1 text-xs text-neutral-400">2 min ago</p>
</div>
<button class="shrink-0 text-neutral-400 transition hover:text-neutral-600 dark:hover:text-neutral-200">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
</div>Free to use in personal and commercial projects. No attribution required.
Variants
Same component, different looks. Preview each one live and copy the code you like.
New like
The rose like variant fits social apps where engagement notifications need warmth.
New like
Amir and 12 others liked your photo.
5 min ago
System update
The amber system variant signals updates and warnings that need attention but are not urgent.
Update available
Version 2.4 is ready to install.
1 hr ago
New follower
The emerald follower variant gives growth notifications a positive feel.
New follower
Ali started following you.
3 hrs ago
About this notification card
The notification card is the standard row you see in activity feeds and notification dropdowns: a colored icon on the left, a bold title, one line of message, a timestamp, and a dismiss X pinned to the corner. It compresses everything a user needs to triage an alert into about 80 pixels of height.
The layout is a flex row with items-start. The icon wrapper uses shrink-0 so it never squishes, the text column gets min-w-0 plus flex-1 so long messages truncate instead of pushing the dismiss button off the card, and the timestamp sits in a smaller muted style to stay subordinate. The whole card carries dark mode classes so it works in both themes.
Use it in notification dropdown panels, activity feed rows, stacked toast notifications, and admin dashboards. Keep titles short and let the message carry the detail, since the truncate behavior assumes one line.
A notification dropdown is a triage station. Users scan dozens of alerts and decide in under a second which deserve a tap, which can wait, and which to dismiss. The card compresses that decision into one row: a colored icon for the type, a bold title, one message line, a timestamp for recency, and a dismiss control. Without this density, feeds become walls of text nobody reads.
The row is flex with items-start. The icon wrapper gets shrink-0 so it never squishes, the text column takes min-w-0 plus flex-1 so long messages truncate instead of shoving the dismiss button off the card, and the timestamp sits in smaller muted text. That min-w-0 is the load-bearing detail: without it, flex children refuse to shrink and the layout explodes on narrow screens.
Assign each type a fixed icon and accent color and never swap them: checkmark in green for success, triangle in amber for warnings, info circle in blue for updates. Users learn the mapping in days, and after that they triage the feed by color alone. Keep the icon style consistent; mixing filled and outline icons in one feed looks like two products. For critical alerts, add a subtle left border in the accent color so the severity survives even in grayscale.
The missing empty state is the overlooked failure. Teams design fifty notification variants and forget the zero case, so an all-caught-up user sees a blank dropdown that looks broken. Always design the empty card: a calm icon, You are all caught up, and no dismiss button. An empty feed is good news; the UI should say so.
Where to use it
- ✓ Notification dropdown panels in app headers
- ✓ Activity feed rows in social and team apps
- ✓ Stacked toast notifications for live events
- ✓ Alert lists in admin dashboards
Customization tips
Recolor the icon wrapper per notification type: green for success, amber for warnings, red for errors. Add an unread dot with a small absolute badge, or swap the dismiss X for action buttons like View and Dismiss when the notification needs a response.
Design notes
When to use
A notification card works for alerts the user should read but can dismiss, like a mention, a comment reply, or a system update. The icon gives the type at a glance, the timestamp answers how fresh it is, and the dismiss button lets users clear what they have handled. Grouping these in a feed keeps transient updates from interrupting the current task the way a modal would.
What to avoid
Do not use notification cards for urgent errors that block the user's task, those deserve an inline or modal treatment that cannot be missed. Avoid vague titles like Notification, the title should say what happened in plain words. And do not let dismissed notifications reappear on refresh, that teaches users the dismiss button is decorative.
Accessibility
New notifications should be announced with a polite live region, not an assertive one that interrupts reading. The dismiss button needs an aria-label naming what it dismisses, like dismiss comment notification.
Frequently asked questions
How do I handle messages longer than one line?
The snippet uses truncate for a strict one-liner. If you need two lines, replace truncate with line-clamp-2, which needs no plugin in recent Tailwind versions.
Does the dismiss button work on its own?
Visually yes, functionally it needs your JavaScript. Wire an onClick that removes the notification from state; the button here is the styled affordance for that handler.
Why min-w-0 on the text column?
Flex children refuse to shrink below their content width by default, so a long message would overflow the card. min-w-0 allows the column to shrink, which lets truncate do its job.
How do I add an unread indicator to the notification card?
Add a small 8px dot, usually blue, positioned at the top corner of the avatar or title row, and remove it once the notification is opened. Keep the dot purely decorative with aria-hidden true, and mark the card itself with an unread label for screen readers so the state is announced in words, not just color.
How do I show a notification count badge on a bell icon?
Wrap the bell in a relative container and place an absolutely positioned badge at the top right with the count inside. Cap the display at 99+ so wide numbers do not break the circle. Update the badge with the same state that drives the card list, and hide it entirely when the count hits zero.
Should notifications auto-dismiss?
Only auto-dismiss low-priority toasts after four to six seconds, and pause the timer while the pointer hovers over them. Never auto-dismiss notifications that need a decision, like a permission request or a payment alert. This card is a persistent list item, so it stays until the user dismisses it.
Customize it with our tools
Related elements
Glass card
Frosted glass effect with backdrop blur. Looks best over a colorful background.
Glass Card
Frosted glass card with subtle border and blur.
Hover lift card
Subtle lift plus shadow sells interactivity without layout shift.
Hover Lift Card
Card that lifts with a deepening shadow on hover.
Revenue
$48.2k
12.4%
Stat Card
Metric card with trend indicator.