Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Activity feeds

4 examples. Resize any preview to see it at phone and tablet widths.

Activity Feed

Free

A live workspace feed grouped by day with sticky headers, a sliding type filter, events that blur in at the top, a “new events” pill when you've scrolled away, and pause/resume.

Notifications Panel

Free

An inbox of notifications with an unread filter, mark-all-read and rows that reflow as they are read, in a panel that never changes height.

Hide code
components/blocks/notifications-panel.tsx
"use client";

import { useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { AtSign, CheckCheck, GitPullRequest, MessageSquare, UserPlus } from "lucide-react";

type Kind = "mention" | "review" | "comment" | "invite";
type Item = { id: string; kind: Kind; who: string; text: string; when: string; unread: boolean };

const icons = { mention: AtSign, review: GitPullRequest, comment: MessageSquare, invite: UserPlus };
const initial: Item[] = [
  { id: "1", kind: "mention", who: "Priya Raman", text: "mentioned you in Checkout redesign", when: "4m", unread: true },
  { id: "2", kind: "review", who: "Theo Park", text: "requested your review on #482", when: "32m", unread: true },
  { id: "3", kind: "comment", who: "Ines Moreau", text: "replied to your comment on Pricing page", when: "2h", unread: true },
  { id: "4", kind: "invite", who: "Jonas Weber", text: "invited you to the Growth workspace", when: "Yesterday", unread: false },
  { id: "5", kind: "comment", who: "Amara Okafor", text: "resolved a thread in Onboarding", when: "Mon", unread: false },
];

export default function NotificationsPanel() {
  const reduce = useReducedMotion();
  const [items, setItems] = useState(initial);
  const [tab, setTab] = useState<"all" | "unread">("all");
  const unread = items.filter((item) => item.unread).length;
  const shown = tab === "unread" ? items.filter((item) => item.unread) : items;

  return (
    <section aria-label="Notifications" className="mx-auto w-full max-w-md px-4 py-10 sm:py-14">
      <div className="overflow-hidden rounded-2xl border border-border bg-card">
        <div className="flex items-center justify-between gap-3 border-b border-border py-2 pl-4 pr-2">
          <div role="group" aria-label="Filter" className="flex gap-1">
            {(["all", "unread"] as const).map((option) => (
              <button key={option} type="button" aria-pressed={tab === option} onClick={() => setTab(option)} className="h-8 rounded-md px-2.5 text-sm capitalize text-muted-foreground outline-none transition-colors duration-150 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:bg-accent aria-pressed:font-medium aria-pressed:text-foreground">
                {option}{option === "unread" ? <span className="ml-1.5 tabular-nums text-muted-foreground">{unread}</span> : null}
              </button>
            ))}
          </div>
          <button type="button" disabled={!unread} onClick={() => setItems((all) => all.map((item) => ({ ...item, unread: false })))} className="inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-sm text-muted-foreground outline-none transition-colors duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40">
            <CheckCheck className="size-4" aria-hidden /> Mark all read
          </button>
        </div>
        {/* A fixed height keeps the panel from resizing when the filter changes. */}
        <ul className="h-[23rem] overflow-y-auto overscroll-contain">
          <AnimatePresence initial={false} mode="popLayout">
            {shown.map((item) => {
              const Icon = icons[item.kind];
              return (
                <motion.li
                  key={item.id}
                  layout={!reduce}
                  initial={{ opacity: 0 }}
                  animate={{ opacity: 1 }}
                  exit={{ opacity: 0 }}
                  transition={{ type: "spring", duration: 0.35, bounce: 0 }}
                  className="border-b border-border last:border-0"
                >
                  <button type="button" onClick={() => setItems((all) => all.map((other) => (other.id === item.id ? { ...other, unread: false } : other)))} className="flex w-full items-start gap-3 px-4 py-3.5 text-left outline-none transition-colors duration-150 hover:bg-accent/60 focus-visible:bg-accent/60 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring">
                    <span className="mt-0.5 grid size-8 shrink-0 place-items-center rounded-full border border-border bg-background text-muted-foreground"><Icon className="size-4" aria-hidden /></span>
                    <span className="min-w-0 flex-1 text-sm leading-snug">
                      <span className="font-medium">{item.who}</span> <span className="text-muted-foreground">{item.text}</span>
                      <span className="mt-1 block text-xs text-muted-foreground">{item.when}</span>
                    </span>
                    <span className={`mt-2 size-2 shrink-0 rounded-full bg-[#e2633a] transition-opacity duration-200 ${item.unread ? "" : "opacity-0"}`}>
                      <span className="sr-only">{item.unread ? "Unread" : ""}</span>
                    </span>
                  </button>
                </motion.li>
              );
            })}
          </AnimatePresence>
          {shown.length === 0 ? <li className="grid h-full place-items-center px-6 text-center text-sm text-muted-foreground">You are all caught up.</li> : null}
        </ul>
      </div>
    </section>
  );
}

Audit Log

Pro

A searchable record of who did what: filters for type, person and dates, events grouped under day headings that stay in view, sensitive actions marked, a side sheet of details and a load-more control.

The source for this block is part of Truffle Pro.

Notification Center

Pro

A full notifications page: unread count, filters, groups by day, rows that can be approved or declined in place, mark-as-read for one or all, and channel switches that open above the list.

The source for this block is part of Truffle Pro.