Notification center in WordPress
A bell with an unread badge that opens a notification panel: icons by type, read and unread items told apart, and a "Mark all as read" button.
Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.
This component also comes in
The code in WordPress
<?php
/**
* Plugin Name: Forge, Centre de notifications
* Description: Une cloche avec pastille de non-lues qui ouvre un panneau de notifications : icônes par type, lues et non lues distinguées, et bouton « Tout marquer comme lu ». Ajoute la composition « Centre de notifications » à l'éditeur de blocs.
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 8.1
* Author: Forge
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: forge-centre-notifications
*<!-- wp:html -->
<div class="notif" data-notif>
<div class="notif__bar">
<p class="notif__brand"><span class="notif__logo" aria-hidden="true">F</span><span>La Fabrique <span class="notif__role">Espace gérant</span></span></p>
<button type="button" class="notif__toggle" aria-expanded="false" aria-controls="notif-panel" aria-label="Notifications, 3 non lues" data-notif-toggle data-enhanced hidden>
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15zM10 20.5a2 2 0 0 0 4 0"/></svg>
<span class="notif__badge" aria-hidden="true" data-notif-badge>3</span>
</button>
</div>
<section class="notif__panel" id="notif-panel" aria-labelledby="notif-title" data-notif-panel>
<div class="notif__head">
<div>(() => {
if (!document.querySelector(".notif")) return;
document.querySelectorAll("[data-notif]").forEach((root) => {
const toggle = root.querySelector("[data-notif-toggle]");
const panel = root.querySelector("[data-notif-panel]");
const badge = root.querySelector("[data-notif-badge]");
const markAll = root.querySelector("[data-notif-all]");
const count = root.querySelector("[data-notif-count]");
const status = root.querySelector("[data-notif-status]");
const label = (n) => `${n} non lue${n > 1 ? "s" : ""}`;
function refresh() {:root {
--notif-text: #18181b;
--notif-muted: #52525b;
--notif-faint: #71717a;
--notif-card: #ffffff;
--notif-hover: #f4f4f5;
--notif-unread-bg: #f8fafc;
--notif-line: #e4e4e7;
--notif-link: #1d4ed8;
--notif-dot: #2563eb;
--notif-ring: #2563eb;
--notif-badge: #dc2626;Free component: copy it freely, including for commercial projects.
Other toasts and alerts components in WordPress
Toasts and alerts components in WordPress
A banner that warns visitors when they lose the network and announces when it is back, using browser events, with no request.
- Tailwind
- React
- CSS
- WordPress

The four classic interface messages: information, success, warning and error.
- Tailwind
- React
- CSS
- WordPress

Three callouts for technical documentation: note, tip and warning.
- Tailwind
- React
- CSS
- WordPress

A notice warning of a scheduled service interruption, with date, time and impact.
- Tailwind
- React
- CSS
- WordPress

A dashed callout highlighting an offer and its code, with the end date.
- Tailwind
- React
- CSS
- WordPress

An announcement bar at the top of the page with a link and a button to close it.
- Tailwind
- React
- CSS
- WordPress