A complete drop-in Social Listening & Brand Sentiment tracking module featuring live channel/sentiment filters (X, TikTok, Reddit, YouTube), an interactive velocity timeline with spike alerts, and an escalatable mention stream.
// Install: npx shadcn@latest add card badge button input tabs && npm i recharts lucide-react
'use client'
import { useMemo, useState } from 'react'
import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
import { AlertTriangle, Flag, Search } from 'lucide-react'
export type SocialChannel = 'X' | 'TikTok' | 'Reddit' | 'YouTube'
export type SentimentTone = 'positive' | 'neutral' | 'negative'
export interface BrandMention {
id: string
author: string
channel: SocialChannel
sentiment: SentimentTone
reach: number
engagements: number
timeAgo: string
text: string
escalated?: boolean
}
const SAMPLE_MENTIONS: BrandMention[] = [
{ id: '1', author: '@linh_builds', channel: 'X', sentiment: 'positive', reach: 48200, engagements: 912, timeAgo: '12m', text: 'Tested the new #launch-v4 dashboard filter — zero lag even with 50k rows.' },
{ id: '2', author: '@growth_mina', channel: 'TikTok', sentiment: 'positive', reach: 124000, engagements: 4820, timeAgo: '28m', text: '30-second breakdown of how #launch-v4 cut onboarding drop-off by 19%.' },
{ id: '3', author: 'u/devops_khang', channel: 'Reddit', sentiment: 'negative', reach: 19400, engagements: 164, timeAgo: '41m', text: 'Webhook retry logs are buried two clicks deep on mobile screens.', escalated: true },
{ id: '4', author: '@studio_tuan', channel: 'YouTube', sentiment: 'positive', reach: 83500, engagements: 2140, timeAgo: '1h', text: 'Full teardown comparing sentiment accuracy across modern monitoring stacks.' },
]
const VELOCITY_DATA = [
{ day: 'Mon', volume: 410, positive: 280 },
{ day: 'Tue', volume: 520, positive: 360 },
{ day: 'Wed', volume: 495, positive: 342 },
{ day: 'Thu', volume: 780, positive: 575 },
{ day: 'Fri', volume: 910, positive: 690 },
{ day: 'Sat', volume: 660, positive: 495 },
{ day: 'Sun', volume: 740, positive: 562 },
]
export function SocialListeningPulse({ mentions = SAMPLE_MENTIONS }: { mentions?: BrandMention[] }) {
const [channel, setChannel] = useState<'all' | SocialChannel>('all')
const [sentiment, setSentiment] = useState<'all' | SentimentTone>('all')
const [query, setQuery] = useState('')
const [flagged, setFlagged] = useState<Record<string, boolean>>(() =>
Object.fromEntries(mentions.filter((m) => m.escalated).map((m) => [m.id, true])),
)
const filtered = useMemo(() => {
const q = query.trim().toLowerCase()
return mentions.filter((m) => {
if (channel !== 'all' && m.channel !== channel) return false
if (sentiment !== 'all' && m.sentiment !== sentiment) return false
return !q || m.text.toLowerCase().includes(q) || m.author.toLowerCase().includes(q)
})
}, [mentions, channel, sentiment, query])
const netSentiment = useMemo(() => {
if (!filtered.length) return 0
const pos = filtered.filter((m) => m.sentiment === 'positive').length
const neg = filtered.filter((m) => m.sentiment === 'negative').length
return Math.round(((pos - neg) / filtered.length) * 100)
}, [filtered])
return (
<section className="space-y-4 rounded-2xl border border-slate-800 bg-[#0b1020] p-5 text-slate-50">
<div className="flex flex-wrap items-center justify-between gap-3">
<div>
<h2 className="text-lg font-semibold tracking-tight">Social Listening Pulse</h2>
<p className="text-xs text-slate-400">Live sentiment velocity & multi-channel brand mentions</p>
</div>
<div className="relative w-full sm:w-64">
<Search className="pointer-events-none absolute left-3 top-2.5 h-4 w-4 text-slate-400" />
<input
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Filter keyword or @handle…"
className="w-full rounded-lg border border-slate-700 bg-slate-900/90 py-2 pl-9 pr-3 text-xs text-slate-100 outline-none focus:border-pink-500"
/>
</div>
</div>
<div className="flex flex-wrap items-center justify-between gap-2">
<div className="flex flex-wrap gap-1.5">
{(['all', 'X', 'TikTok', 'Reddit', 'YouTube'] as const).map((ch) => (
<button
key={ch}
type="button"
onClick={() => setChannel(ch)}
className="rounded-full border px-3 py-1 text-xs font-medium transition"
style={{
borderColor: channel === ch ? '#ec4899' : 'rgba(148,163,184,0.2)',
background: channel === ch ? '#ec489924' : 'transparent',
}}
>
{ch === 'all' ? 'All Channels' : ch}
</button>
))}
</div>
<div className="flex gap-1 rounded-lg border border-slate-800 bg-slate-900/70 p-1 text-xs">
{(['all', 'positive', 'neutral', 'negative'] as const).map((tone) => (
<button
key={tone}
type="button"
onClick={() => setSentiment(tone)}
className="rounded-md px-2.5 py-1 capitalize"
style={{
background: sentiment === tone ? 'linear-gradient(135deg, #ec4899, #06b6d4)' : 'transparent',
color: sentiment === tone ? '#fff' : '#94a3b8',
}}
>
{tone}
</button>
))}
</div>
</div>
<div className="grid gap-4 lg:grid-cols-12">
<div className="rounded-xl border border-slate-800 bg-slate-900/60 p-4 lg:col-span-7">
<div className="mb-3 flex items-center justify-between">
<span className="text-xs font-semibold uppercase tracking-wider text-slate-400">
Sentiment Velocity · Net {netSentiment >= 0 ? '+' : ''}{netSentiment}%
</span>
<span className="inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-[11px] font-medium" style={{ background: '#ec489922', color: '#ec4899' }}>
<AlertTriangle className="h-3 w-3" /> 3.2× spike on #launch-v4
</span>
</div>
<div className="h-56 w-full">
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={VELOCITY_DATA}>
<CartesianGrid strokeDasharray="3 3" stroke="rgba(148,163,184,0.12)" />
<XAxis dataKey="day" stroke="#94a3b8" fontSize={11} />
<YAxis stroke="#94a3b8" fontSize={11} />
<Tooltip contentStyle={{ background: '#0f172a', border: '1px solid #334155', borderRadius: 10 }} />
<Area type="monotone" dataKey="volume" stroke="#ec4899" fill="#ec4899" fillOpacity={0.22} strokeWidth={2.5} />
<Area type="monotone" dataKey="positive" stroke="#06b6d4" fill="#06b6d4" fillOpacity={0.12} strokeWidth={2} />
</AreaChart>
</ResponsiveContainer>
</div>
</div>
<div className="space-y-2.5 lg:col-span-5">
{filtered.map((item) => {
const isFlagged = Boolean(flagged[item.id])
return (
<article key={item.id} className="rounded-xl border border-slate-800 bg-slate-900/60 p-3">
<div className="flex items-center justify-between gap-2 text-xs">
<strong className="font-semibold text-white">{item.author}</strong>
<span className="text-[11px] text-slate-400">{item.channel} · {item.timeAgo}</span>
</div>
<p className="mt-1.5 text-xs leading-relaxed text-slate-300">{item.text}</p>
<div className="mt-2.5 flex items-center justify-between text-[11px] text-slate-400">
<span>Reach {(item.reach / 1000).toFixed(1)}K · {item.engagements} eng</span>
<button
type="button"
onClick={() => setFlagged((prev) => ({ ...prev, [item.id]: !prev[item.id] }))}
className="inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium"
style={{
borderColor: isFlagged ? '#ec4899' : 'rgba(148,163,184,0.22)',
background: isFlagged ? '#ec4899' : 'transparent',
color: isFlagged ? '#fff' : '#cbd5e1',
}}
>
<Flag className="h-3 w-3" /> {isFlagged ? 'Escalated' : 'Flag'}
</button>
</div>
</article>
)
})}
</div>
</div>
</section>
)
}Loading single-file HTML…
Build a single-file interactive Social Listening & Brand Sentiment Tracking web module compatible with shadcn/ui, Tailwind CSS v4, Recharts, and Lucide React on a high-contrast slate canvas (#0b1020) with a Light Editorial mode toggle. - Live KPI Strip & Multi-Axis Filters: Render 4 tabular-num KPI cards (Filtered Mentions, Net Sentiment %, Estimated Reach, Escalated Alerts) that recalculate dynamically across channel pills (All, X, TikTok, Reddit, YouTube), sentiment segments (All, Positive, Neutral, Negative), 7D/30D range toggle, and real-time keyword/@handle search. - Interactive Sentiment Timeline & Spike Watch: Plot Total Mention Volume vs. Positive Share with hover/click point inspection readouts and a highlighted keyword spike alert banner (#ec4899 / #06b6d4). - Actionable Mention Stream: Display scrollable brand mentions with channel badges, sentiment pills, reach/engagement counts, and a 1-click Flag / Escalate toggle with toast feedback, fully responsive down to 390px mobile.
WHY THIS WORKS IN PRODUCTION
- Complete drop-in social listening workbench with live channel, sentiment & keyword filtering
- Interactive 7D / 30D sentiment velocity chart with hover inspection & keyword spike alert banner
- Actionable mention stream with 1-click escalation flags, live KPI recalculation & Light/Dark toggle
- Single-file TypeScript component ready for shadcn/ui + Recharts + Tailwind CSS v4
DROP-IN SPECS // WEB & MOBILE FIT







