Notification Centre
A working notification centre with illustrative data and frontend interactions.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/notification-centre.jsonUse it
Scroll horizontally for long lines
"use client";
import {NotificationCentre} from '@/components/jez-ui/blocks/notification-centre';
export default function Example(){
return <><NotificationCentre/></>;
}Props & types
Scroll horizontally for long lines
{ className?: string }Source
View 3 source files
registry/blocks/notification-centre.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { CheckCheck, Download, AtSign, CircleCheck } from "lucide-react";
import { cn } from "../ui/utils";
import { Button } from "../ui/button";
export function NotificationCentre({ className }: { className?: string }) {
const [read, setRead] = React.useState<string[]>([]);
const [unreadOnly, setUnreadOnly] = React.useState(false);
const items = [
{
title: "Your export is ready",
detail: "September report · CSV",
time: "2m",
icon: Download,
},
{
title: "Sam mentioned you in a comment",
detail: "“Can you take a look at the updated brief?”",
time: "18m",
icon: AtSign,
},
{
title: "A project is ready for review",
detail: "Field notes · Homepage exploration",
time: "1h",
icon: CircleCheck,
},
];
return (
<section
className={cn(
"overflow-hidden rounded-xl border border-border",
className,
)}
>
<div className="flex flex-wrap items-center justify-between gap-3 p-5">
<h2 className="text-lg font-semibold">
Inbox{" "}
<span className="ml-1 text-sm text-muted-foreground">
{items.length - read.length}
</span>
</h2>
<Button
size="sm"
variant="ghost"
onClick={() => setRead(items.map((i) => i.title))}
>
<CheckCheck size={15} />
Mark all read
</Button>
</div>
<div className="flex gap-5 border-b border-border px-5">
{[false, true].map((v) => (
<button
key={String(v)}
onClick={() => setUnreadOnly(v)}
className={cn(
"border-b-2 pb-3 text-sm",
unreadOnly === v
? "border-primary font-medium"
: "border-transparent text-muted-foreground",
)}
>
{v ? "Unread" : "All activity"}
</button>
))}
</div>
{items
.filter((i) => !unreadOnly || !read.includes(i.title))
.map((i) => (
<button
key={i.title}
onClick={() =>
setRead((r) => (r.includes(i.title) ? r : [...r, i.title]))
}
className={cn(
"flex w-full items-start gap-3 border-b border-border/60 p-5 text-left transition-colors last:border-0 hover:bg-muted/40",
!read.includes(i.title) && "bg-primary/3",
)}
>
<span className="grid size-9 shrink-0 place-items-center rounded-full border border-border bg-background">
<i.icon size={16} />
</span>
<span className="min-w-0 flex-1">
<span className="block text-sm font-medium">{i.title}</span>
<span className="mt-1 block text-xs leading-relaxed text-muted-foreground">
{i.detail}
</span>
</span>
<span className="grid justify-items-end gap-2 text-xs text-muted-foreground">
{i.time}
{!read.includes(i.title) && (
<span className="size-1.5 rounded-full bg-primary" />
)}
<span className="sr-only">
{read.includes(i.title) ? "Read" : "Unread"}
</span>
</span>
</button>
))}
{unreadOnly && read.length === items.length && (
<p className="p-10 text-center text-sm text-muted-foreground">
You’re all caught up.
</p>
)}
</section>
);
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
registry/ui/button.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Slot } from "radix-ui";
import { LoaderCircle } from "lucide-react";
import { cn } from "./utils";
export type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
variant?: "primary" | "secondary" | "outline" | "ghost" | "danger";
size?: "sm" | "md" | "lg";
loading?: boolean;
asChild?: boolean;
};
export function Button({
variant = "primary",
size = "md",
loading,
asChild,
className,
children,
disabled,
...props
}: ButtonProps) {
const Comp = asChild ? Slot.Root : "button";
return (
<Comp
type={asChild ? undefined : "button"}
disabled={asChild ? undefined : disabled || loading}
aria-disabled={disabled || loading || undefined}
aria-busy={loading || undefined}
className={cn(
"relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-transparent text-sm font-medium leading-none transition-[background-color,border-color,box-shadow,transform] duration-150 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-[.98] disabled:pointer-events-none disabled:opacity-45 aria-disabled:pointer-events-none [&_svg]:shrink-0",
{
"bg-primary text-primary-foreground shadow-[inset_0_1px_0_#ffffff26,0_1px_2px_#00000012] hover:bg-primary/90":
variant === "primary",
"border-border/60 bg-muted text-foreground hover:bg-muted/70":
variant === "secondary",
"border-border bg-background text-foreground shadow-sm hover:bg-muted/60":
variant === "outline",
"text-muted-foreground hover:bg-muted hover:text-foreground":
variant === "ghost",
"bg-danger text-danger-foreground hover:bg-danger/90":
variant === "danger",
},
{
"h-8 px-3 text-xs": size === "sm",
"h-10 px-4": size === "md",
"h-12 px-6": size === "lg",
},
className,
)}
{...props}
>
{asChild ? (
children
) : (
<>
<span
className={cn(
"inline-flex min-w-0 flex-1 items-center justify-center gap-2",
loading && "invisible",
)}
>
{children}
</span>
{loading && (
<LoaderCircle
aria-hidden="true"
className="absolute size-4 animate-spin motion-reduce:animate-none"
/>
)}
</>
)}
</Comp>
);
}
Dependencies
lucide-react@0.577.0 · clsx@2.1.1 · tailwind-merge@3.5.0 · radix-ui@1.6.7
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →