Accounts Table
A polished B2B SaaS accounts data grid with brand logo cells, multi-tag market segments, currency pills, ISO date cells, and interactive filter chips. Includes row selection, sortable columns, tag filtering, and a live search — all wired with motion layout transitions.
TableReactFramer MotionTailwind CSSPhosphor Icons
CSSTailwind
Manual
Create a file and paste the following code into it.
src/components/accounts-table.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
"use client";
import {
useId,
useMemo,
useState,
type ComponentType,
type ReactNode,
} from "react";
import Image from "next/image";
import { AnimatePresence, motion, type Transition } from "motion/react";
import {
CurrencyDollar,
FunnelSimple,
Globe,
MagnifyingGlass,
Plus,
SlidersHorizontal,
SquaresFour,
X,
CalendarBlank,
FolderSimple,
} from "@phosphor-icons/react";
/* ═══════════════════════════════════════════════
Utility
═══════════════════════════════════════════════ */
function cn(...parts: Array<string | false | null | undefined>) {
return parts.filter(Boolean).join(" ");
}
const EASE_OUT = [0.23, 1, 0.32, 1] as const;
const LAYOUT_TRANSITION: Transition = {
type: "spring",
stiffness: 420,
damping: 36,
};
/* ═══════════════════════════════════════════════
Domain Types
═══════════════════════════════════════════════ */
type MarketSegment =
| "SaaS"
| "AI"
| "Security"
| "Data Tech"
| "Legal Tech"
| "Financial Services"
| "Hard + Software";
interface ContractValue {
period: "Month" | "Year";
amount: number;
}
interface Account {
id: string;
name: string;
logo: string;
domain: string;
contractValue?: ContractValue;
renewalDate?: string;
lastInteraction: string;
segments: MarketSegment[];
contact?: string;
}
type SortKey = "name" | "domain" | "contractValue" | "renewalDate";
type SortDirection = "asc" | "desc";
interface SortConfig {
key: SortKey;
direction: SortDirection;
}
/* ═══════════════════════════════════════════════
Seed Data
═══════════════════════════════════════════════ */
const LOGO = (slug: string) => `/logos/accounts-table/${slug}.svg`;
const ACCOUNTS: readonly Account[] = [
{
id: "adobe",
name: "Adobe",
logo: LOGO("adobe"),
domain: "adobe.com",
contractValue: { period: "Month", amount: 0 },
lastInteraction: "Aug 22",
segments: ["SaaS", "AI"],
contact: "Marcus Chen",
},
{
id: "brex",
name: "Brex",
logo: LOGO("brex"),
domain: "brex.com",
lastInteraction: "Aug 22",
segments: ["SaaS", "Financial Services"],
contact: "Sofia Rodriguez",
},
{
id: "datadog",
name: "Datadog",
logo: LOGO("datadog"),
domain: "datadog.com",
lastInteraction: "Aug 22",
segments: ["SaaS", "AI", "Security", "Data Tech"],
contact: "James Nakamura",
},
{
id: "docusign",
name: "DocuSign",
logo: LOGO("docusign"),
domain: "docusign.com",
renewalDate: "2025-09-23",
lastInteraction: "Aug 22",
segments: ["SaaS", "Legal Tech"],
contact: "Emma Zhu",
},
{
id: "microsoft",
name: "Microsoft",
logo: LOGO("microsoft"),
domain: "microsoft.com",
contractValue: { period: "Year", amount: 25000 },
lastInteraction: "Aug 22",
segments: ["SaaS", "Security", "Data Tech"],
contact: "Raj Patel",
},
{
id: "ramp",
name: "Ramp",
logo: LOGO("ramp"),
domain: "ramp.com",
lastInteraction: "Aug 22",
segments: ["SaaS", "Financial Services"],
},
{
id: "rippling",
name: "Rippling",
logo: LOGO("rippling"),
domain: "rippling.com",
lastInteraction: "Aug 22",
segments: ["SaaS", "Financial Services"],
contact: "Claire Dubois",
},
{
id: "salesforce",
name: "Salesforce",
logo: LOGO("salesforce"),
domain: "salesforce.com",
renewalDate: "2025-09-23",
lastInteraction: "Aug 22",
segments: ["SaaS", "AI"],
},
{
id: "stripe",
name: "Stripe",
logo: LOGO("stripe"),
domain: "stripe.com",
renewalDate: "2025-09-23",
lastInteraction: "Aug 22",
segments: ["SaaS", "Financial Services"],
},
{
id: "workday",
name: "Workday",
logo: LOGO("workday"),
domain: "workday.com",
contractValue: { period: "Year", amount: 1000000 },
lastInteraction: "Aug 22",
segments: ["SaaS", "AI"],
contact: "Gino Emannuel",
},
{
id: "zoom",
name: "Zoom",
logo: LOGO("zoom"),
domain: "zoom.us",
lastInteraction: "Aug 22",
segments: ["SaaS"],
},
{
id: "berryai",
name: "Berryai",
logo: LOGO("berryai"),
domain: "berryai.com",
lastInteraction: "Aug 22",
segments: ["Hard + Software", "SaaS"],
},
];
/* ═══════════════════════════════════════════════
Visual Tokens
═══════════════════════════════════════════════ */
const SEGMENT_STYLES: Record<
MarketSegment,
{ bg: string; text: string; border: string; dot: string }
> = {
SaaS: {
bg: "bg-violet-50",
text: "text-violet-700",
border: "border-violet-200/70",
dot: "bg-violet-500",
},
AI: {
bg: "bg-rose-50",
text: "text-rose-700",
border: "border-rose-200/70",
dot: "bg-rose-500",
},
Security: {
bg: "bg-emerald-50",
text: "text-emerald-700",
border: "border-emerald-200/70",
dot: "bg-emerald-500",
},
"Data Tech": {
bg: "bg-red-50",
text: "text-red-700",
border: "border-red-200/70",
dot: "bg-red-500",
},
"Legal Tech": {
bg: "bg-orange-50",
text: "text-orange-700",
border: "border-orange-200/70",
dot: "bg-orange-500",
},
"Financial Services": {
bg: "bg-pink-50",
text: "text-pink-700",
border: "border-pink-200/70",
dot: "bg-pink-500",
},
"Hard + Software": {
bg: "bg-amber-50",
text: "text-amber-700",
border: "border-amber-200/70",
dot: "bg-amber-500",
},
};
const ALL_SEGMENTS: readonly MarketSegment[] = [
"SaaS",
"AI",
"Security",
"Data Tech",
"Legal Tech",
"Financial Services",
"Hard + Software",
];
/* ═══════════════════════════════════════════════
Helpers
═══════════════════════════════════════════════ */
function formatCurrency({ period, amount }: ContractValue) {
if (amount === 0) return `${period} | $0`;
if (amount >= 1_000_000) return `${period} | $${amount / 1_000_000}M`;
if (amount >= 1_000) return `${period} | $${amount / 1_000}k`;
return `${period} | $${amount}`;
}
function sortAccounts(
list: readonly Account[],
config: SortConfig | null,
): Account[] {
if (!config) return [...list];
const sign = config.direction === "asc" ? 1 : -1;
return [...list].sort((a, b) => {
switch (config.key) {
case "name":
return a.name.localeCompare(b.name) * sign;
case "domain":
return a.domain.localeCompare(b.domain) * sign;
case "contractValue": {
const av = a.contractValue?.amount ?? -1;
const bv = b.contractValue?.amount ?? -1;
return (av - bv) * sign;
}
case "renewalDate": {
const av = a.renewalDate ?? "";
const bv = b.renewalDate ?? "";
if (!av && bv) return 1;
if (av && !bv) return -1;
return av.localeCompare(bv) * sign;
}
}
});
}
function filterAccounts(
list: readonly Account[],
query: string,
segments: ReadonlySet<MarketSegment>,
): Account[] {
const q = query.trim().toLowerCase();
const required = [...segments];
return list.filter((account) => {
if (q && !account.name.toLowerCase().includes(q)) return false;
if (required.length === 0) return true;
return required.every((s) => account.segments.includes(s));
});
}
/* ═══════════════════════════════════════════════
Atoms
═══════════════════════════════════════════════ */
const TOOLBAR_LIGHT_BUTTON =
"inline-flex h-7 items-center gap-1.5 rounded-md bg-gradient-to-b from-white to-zinc-100 px-2.5 text-[12px] font-semibold text-zinc-900 shadow-[inset_0_0.5px_0_rgba(255,255,255,0.9),inset_0_-0.5px_0.6px_rgba(0,0,0,0.06),0_1.5px_3px_-0.5px_rgba(0,0,0,0.15),0_0_0_1px_rgba(0,0,0,0.08)] transition-[filter,transform] duration-150 hover:brightness-[0.97] active:scale-[0.97]";
function HeaderBar({ onAdd }: { onAdd: () => void }) {
return (
<div className={cn("flex items-center gap-2 p-2", SURFACE_GRAY)}>
<div className="flex h-10 shrink-0 items-center gap-2 rounded-lg bg-zinc-950 pl-3 pr-1.5 ring-1 ring-black/5">
<span className="text-[14px] font-semibold tracking-[-0.005em] text-white">
Accounts
</span>
<button
type="button"
className="inline-flex h-7 items-center gap-1.5 rounded-md bg-stone-700 px-2 text-[12px] font-semibold text-zinc-300 shadow-[inset_0_0.5px_0.5px_rgba(255,255,255,0.14),inset_0_-0.5px_0.6px_rgba(0,0,0,0.35),0_1.5px_3px_-0.5px_rgba(0,0,0,0.4),0_0_0_1px_rgba(255,255,255,0.1)] transition-[background-color,transform] duration-150 hover:bg-stone-600 active:scale-[0.97]"
>
<FolderSimple size={12} weight="duotone" className="text-zinc-400" />
B2B SaaS Accounts
</button>
</div>
<div className="flex h-10 flex-1 items-center justify-end gap-1.5 rounded-lg bg-zinc-950 pl-3 pr-1.5 ring-1 ring-black/5">
<button type="button" onClick={onAdd} className={TOOLBAR_LIGHT_BUTTON}>
Add
<Plus size={11} weight="bold" className="text-zinc-500" />
</button>
<button type="button" className={TOOLBAR_LIGHT_BUTTON}>
View
<SlidersHorizontal size={11} weight="bold" className="text-zinc-500" />
</button>
</div>
</div>
);
}
interface FilterChip {
label: string;
icon?: ComponentType<{ size?: number; weight?: "duotone" | "bold" | "regular" }>;
active?: boolean;
removable?: boolean;
onToggle?: () => void;
onRemove?: () => void;
}
function FilterChipButton({ chip }: { chip: FilterChip }) {
const Icon = chip.icon;
const colorClass = chip.active
? "border-violet-300/80 bg-violet-50 text-violet-700 hover:border-violet-400 hover:bg-violet-100"
: "border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300 hover:text-zinc-900";
if (!chip.removable) {
return (
<button
type="button"
onClick={chip.onToggle}
className={cn(
"inline-flex h-8 items-center gap-1.5 rounded-lg border px-2.5 text-[13px] font-semibold transition-colors duration-150 active:scale-[0.97]",
colorClass,
)}
>
{Icon ? <Icon size={13} weight="duotone" /> : null}
{chip.label}
</button>
);
}
return (
<span
className={cn(
"inline-flex h-8 items-center rounded-lg border text-[13px] font-semibold transition-colors duration-150",
colorClass,
)}
>
<button
type="button"
onClick={chip.onToggle}
className="inline-flex items-center gap-1.5 self-stretch pl-2.5 pr-1 active:scale-[0.97]"
>
{Icon ? <Icon size={13} weight="duotone" /> : null}
{chip.label}
</button>
<button
type="button"
onClick={chip.onRemove}
aria-label={`Remove ${chip.label} filter`}
className="mr-1 inline-flex size-4 items-center justify-center rounded text-current/70 transition-colors hover:bg-violet-200/70 hover:text-violet-800"
>
<X size={10} weight="bold" />
</button>
</span>
);
}
interface FilterBarProps {
query: string;
onQueryChange: (value: string) => void;
activeSegments: ReadonlySet<MarketSegment>;
onToggleSegment: (segment: MarketSegment) => void;
onClearSegment: (segment: MarketSegment) => void;
}
function MarketSegmentFilter({
activeSegments,
onToggleSegment,
onClearSegment,
}: {
activeSegments: ReadonlySet<MarketSegment>;
onToggleSegment: (segment: MarketSegment) => void;
onClearSegment: (segment: MarketSegment) => void;
}) {
const [open, setOpen] = useState(false);
const hasSelections = activeSegments.size > 0;
return (
<div className="relative">
<div
className={cn(
"inline-flex h-8 items-stretch overflow-hidden rounded-lg border bg-white transition-colors",
hasSelections ? "border-zinc-300" : "border-zinc-200",
)}
>
<button
type="button"
onClick={() => setOpen((prev) => !prev)}
className="inline-flex items-center gap-1.5 px-2.5 text-[13px] font-semibold text-zinc-600 transition-colors hover:text-zinc-900 active:scale-[0.97]"
>
<SquaresFour size={13} weight="duotone" />
Market Segments
</button>
{hasSelections ? (
<>
<span aria-hidden className="my-1.5 w-px bg-zinc-200" />
<div className="flex items-center gap-1 pl-1.5 pr-1">
<AnimatePresence mode="popLayout">
{[...activeSegments].map((segment) => (
<motion.span
key={segment}
layout
initial={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.18, ease: EASE_OUT }}
className="inline-flex items-center gap-0.5 rounded border border-violet-200/80 bg-violet-50 py-0.5 pl-1.5 pr-0.5 text-[12px] font-semibold text-violet-700"
>
{segment}
<button
type="button"
onClick={(event) => {
event.stopPropagation();
onClearSegment(segment);
}}
aria-label={`Remove ${segment} filter`}
className="ml-0.5 inline-flex size-4 items-center justify-center rounded text-violet-500/80 transition-colors hover:bg-violet-100 hover:text-violet-800"
>
<X size={10} weight="bold" />
</button>
</motion.span>
))}
</AnimatePresence>
</div>
</>
) : null}
</div>
<AnimatePresence>
{open ? (
<motion.div
key="segment-menu"
initial={{ opacity: 0, y: -4, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: -4, scale: 0.98 }}
transition={{ duration: 0.18, ease: EASE_OUT }}
className="absolute left-0 top-[calc(100%+6px)] z-20 w-[220px] origin-top-left rounded-lg border border-zinc-200 bg-white p-1 shadow-lg shadow-zinc-900/5"
>
{ALL_SEGMENTS.map((segment) => {
const active = activeSegments.has(segment);
const style = SEGMENT_STYLES[segment];
return (
<button
key={segment}
type="button"
onClick={() => onToggleSegment(segment)}
className={cn(
"flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-[13px] transition-colors",
active
? "bg-zinc-50 text-zinc-900"
: "text-zinc-600 hover:bg-zinc-50 hover:text-zinc-900",
)}
>
<span className="flex items-center gap-2">
<span className={cn("size-1.5 rounded-full", style.dot)} />
{segment}
</span>
{active ? (
<span className="text-[11px] font-semibold text-violet-600">
ON
</span>
) : null}
</button>
);
})}
</motion.div>
) : null}
</AnimatePresence>
</div>
);
}
function FilterBar({
query,
onQueryChange,
activeSegments,
onToggleSegment,
onClearSegment,
}: FilterBarProps) {
const searchId = useId();
return (
<div
className={cn(
"flex flex-wrap items-center justify-between gap-2.5 border-b border-zinc-200/70 px-2 py-2.5",
SURFACE_GRAY,
)}
>
<label
htmlFor={searchId}
className="group relative inline-flex h-8 min-w-0 flex-1 items-center gap-2 rounded-lg border border-zinc-200 bg-white px-2.5 transition-colors focus-within:border-zinc-400 sm:max-w-[320px]"
>
<MagnifyingGlass
size={14}
weight="duotone"
className="shrink-0 text-zinc-400"
/>
<input
id={searchId}
type="text"
value={query}
onChange={(event) => onQueryChange(event.target.value)}
placeholder="Filter Accounts By Name..."
className="w-full min-w-0 bg-transparent text-[13px] font-medium text-zinc-800 placeholder:font-medium placeholder:text-zinc-400 focus:outline-none"
/>
</label>
<div className="flex flex-wrap items-center gap-2">
<MarketSegmentFilter
activeSegments={activeSegments}
onToggleSegment={onToggleSegment}
onClearSegment={onClearSegment}
/>
{(["Stage", "Tier", "Health Pulse", "Account Owner"] as const).map(
(label) => (
<FilterChipButton key={label} chip={{ label }} />
),
)}
<FilterChipButton chip={{ label: "Filter", icon: FunnelSimple }} />
</div>
</div>
);
}
/* ═══════════════════════════════════════════════
Column Config + Header Row
═══════════════════════════════════════════════ */
interface ColumnConfig {
key?: SortKey;
label: string;
width: string;
align?: "left" | "right";
}
const COLUMNS: readonly ColumnConfig[] = [
{ key: "name", label: "Account", width: "200px" },
{ key: "domain", label: "Domain", width: "170px" },
{ key: "contractValue", label: "Contract Value", width: "160px" },
{ key: "renewalDate", label: "Renewal Date", width: "150px" },
{ label: "Last Interaction", width: "150px" },
{ label: "Market Segments", width: "240px" },
{ label: "Contact", width: "170px" },
];
// Static class for Tailwind JIT — must stay in sync with COLUMNS widths.
const ROW_CLASS =
"grid min-w-[1240px] grid-cols-[200px_170px_160px_150px_150px_240px_170px]";
const STICKY_FIRST_CLASS = "sticky left-0";
const SURFACE_GRAY = "bg-[#f4f5f7]";
// Must match the first slot of ROW_CLASS — unified shadow strip uses this.
const ACCOUNT_COL_WIDTH = 200;
const FONT_STACK =
'"Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif';
function TableHeaderRow({
sort,
onSort,
}: {
sort: SortConfig | null;
onSort: (key: SortKey) => void;
}) {
return (
<div
role="row"
className={cn(
ROW_CLASS,
"sticky top-0 z-10 border-b border-zinc-200/70",
SURFACE_GRAY,
)}
>
{COLUMNS.map((column, index) => {
const sortKey = column.key;
const isActive = sortKey !== undefined && sort?.key === sortKey;
const arrow = isActive ? (sort!.direction === "asc" ? "↑" : "↓") : null;
const isFirst = index === 0;
return (
<button
key={column.label}
type="button"
disabled={sortKey === undefined}
onClick={sortKey ? () => onSort(sortKey) : undefined}
role="columnheader"
aria-sort={
isActive
? sort!.direction === "asc"
? "ascending"
: "descending"
: "none"
}
className={cn(
"flex h-10 items-center gap-1 border-r border-zinc-200/60 px-3 text-left text-[13px] font-medium text-zinc-500 transition-colors",
sortKey
? "cursor-pointer hover:text-zinc-900"
: "cursor-default",
isActive && "text-zinc-900",
isFirst && cn(STICKY_FIRST_CLASS, "z-[2] bg-white"),
)}
>
{column.label}
{sortKey ? (
<span className="text-[11px] text-zinc-400">{arrow ?? "⇅"}</span>
) : null}
</button>
);
})}
</div>
);
}
/* ═══════════════════════════════════════════════
Cells
═══════════════════════════════════════════════ */
function Cell({
children,
className,
}: {
children: ReactNode;
className?: string;
}) {
return (
<div
role="cell"
className={cn(
"flex items-center border-r border-zinc-200/60 px-3 py-3 text-[14px]",
className,
)}
>
{children}
</div>
);
}
function AccountCell({
account,
selected,
}: {
account: Account;
selected: boolean;
}) {
return (
<div
role="cell"
className={cn(
"relative flex items-center gap-2.5 border-r border-zinc-200/60 px-3 py-3 text-[14px] transition-colors",
STICKY_FIRST_CLASS,
"z-[1]",
// Opaque white — sticky cell must never be translucent
"bg-white group-hover:bg-[#fafbfc]",
)}
>
{selected ? (
<motion.span
layoutId="selected-indicator"
className="absolute inset-y-0 left-0 w-[3px] rounded-r-sm bg-blue-500"
transition={LAYOUT_TRANSITION}
/>
) : null}
<span className="relative inline-flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-md bg-white ring-1 ring-zinc-200/80">
<Image
src={account.logo}
alt={`${account.name} logo`}
width={20}
height={20}
className="size-5 object-contain"
/>
</span>
<span className="truncate font-semibold text-zinc-900">
{account.name}
</span>
</div>
);
}
function DomainCell({ domain }: { domain: string }) {
return (
<Cell className="gap-1.5 font-medium text-sky-600">
<Globe size={14} weight="duotone" className="shrink-0" />
<span className="truncate">{domain}</span>
</Cell>
);
}
function ContractValueCell({ value }: { value?: ContractValue }) {
if (!value) return <Cell>{null}</Cell>;
return (
<Cell>
<span className="inline-flex items-center gap-1 rounded-md border border-orange-200/70 bg-orange-50 px-2 py-1 text-[12px] font-semibold text-orange-700">
<CurrencyDollar size={11} weight="bold" />
{formatCurrency(value)}
</span>
</Cell>
);
}
function DateCell({ value }: { value?: string }) {
if (!value) return <Cell>{null}</Cell>;
return (
<Cell>
<span className="inline-flex items-center gap-1.5 rounded-md bg-zinc-50 px-2 py-1 text-[12px] font-medium text-zinc-600 ring-1 ring-zinc-200/70">
<CalendarBlank size={12} weight="duotone" className="text-zinc-400" />
{value}
</span>
</Cell>
);
}
function SegmentsCell({ segments }: { segments: MarketSegment[] }) {
return (
<Cell className="min-w-0 gap-1 overflow-hidden">
<div className="flex min-w-0 gap-1">
{segments.map((segment) => {
const style = SEGMENT_STYLES[segment];
return (
<span
key={segment}
className={cn(
"inline-flex shrink-0 items-center rounded-md border px-1.5 py-0.5 text-[12px] font-semibold",
style.bg,
style.text,
style.border,
)}
>
{segment}
</span>
);
})}
</div>
</Cell>
);
}
function ContactCell({ name }: { name?: string }) {
if (!name) return <Cell>{null}</Cell>;
return (
<Cell className="gap-2 font-medium text-zinc-600">
<span
aria-hidden
className="inline-flex size-5 shrink-0 rounded-full bg-zinc-100 ring-1 ring-zinc-200/80"
/>
<span className="truncate">{name}</span>
</Cell>
);
}
/* ═══════════════════════════════════════════════
Row
═══════════════════════════════════════════════ */
interface AccountRowProps {
account: Account;
selected: boolean;
onSelect: (id: string) => void;
}
function AccountRow({ account, selected, onSelect }: AccountRowProps) {
// Row background drives the non-sticky (gray) cells. Sticky cell keeps its
// own white bg so it never reveals scrolled cells through transparency.
// Static Tailwind literals required for JIT scanning.
const rowBgClass = selected
? "bg-[#e6edfa] group-hover:bg-[#dde6f6]"
: "bg-[#f4f5f7] group-hover:bg-[#edeef2]";
return (
<motion.div
layout="position"
transition={LAYOUT_TRANSITION}
initial={{ opacity: 0, y: -6 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 6 }}
role="row"
aria-selected={selected}
onClick={() => onSelect(account.id)}
className={cn(
ROW_CLASS,
"group relative cursor-pointer border-b border-zinc-200/50 text-zinc-700 transition-colors",
rowBgClass,
)}
>
<AccountCell account={account} selected={selected} />
<DomainCell domain={account.domain} />
<ContractValueCell value={account.contractValue} />
<DateCell value={account.renewalDate} />
<DateCell value={account.lastInteraction} />
<SegmentsCell segments={account.segments} />
<ContactCell name={account.contact} />
</motion.div>
);
}
/* ═══════════════════════════════════════════════
Main Demo
═══════════════════════════════════════════════ */
/**
* B2B SaaS accounts data grid with filter chips, sortable columns,
* row selection, live search, and motion layout transitions.
*/
export default function AccountsTable() {
const [query, setQuery] = useState("");
const [activeSegments, setActiveSegments] = useState<Set<MarketSegment>>(
() => new Set(["SaaS"]),
);
const [sort, setSort] = useState<SortConfig | null>(null);
const [selectedId, setSelectedId] = useState<string | null>("microsoft");
const visibleAccounts = useMemo(() => {
const filtered = filterAccounts(ACCOUNTS, query, activeSegments);
return sortAccounts(filtered, sort);
}, [query, activeSegments, sort]);
const handleSort = (key: SortKey) => {
setSort((current) => {
if (!current || current.key !== key) return { key, direction: "asc" };
if (current.direction === "asc") return { key, direction: "desc" };
return null;
});
};
const handleToggleSegment = (segment: MarketSegment) => {
setActiveSegments((prev) => {
const next = new Set(prev);
if (next.has(segment)) next.delete(segment);
else next.add(segment);
return next;
});
};
const handleClearSegment = (segment: MarketSegment) => {
setActiveSegments((prev) => {
const next = new Set(prev);
next.delete(segment);
return next;
});
};
return (
<div
className="flex min-h-dvh w-full items-center justify-center p-6"
style={{
background:
"linear-gradient(135deg, #eef1f6 0%, #e6ebf3 50%, #dfe5ef 100%)",
fontFamily: FONT_STACK,
}}
>
<link
rel="preconnect"
href="https://fonts.googleapis.com"
/>
<link
rel="preconnect"
href="https://fonts.gstatic.com"
crossOrigin="anonymous"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap"
/>
<div
className={cn(
"w-full max-w-[1240px] overflow-hidden rounded-2xl shadow-[0_24px_64px_-24px_rgba(15,23,42,0.22),0_4px_16px_-4px_rgba(15,23,42,0.08)] ring-1 ring-zinc-300/60",
SURFACE_GRAY,
)}
>
<HeaderBar onAdd={() => undefined} />
<FilterBar
query={query}
onQueryChange={setQuery}
activeSegments={activeSegments}
onToggleSegment={handleToggleSegment}
onClearSegment={handleClearSegment}
/>
<div className="relative">
{/* Shadow strip sits OUTSIDE the scroll container so it stays still
during horizontal scroll and never breaks between rows like a
per-cell shadow would. */}
<div
aria-hidden
className="pointer-events-none absolute top-0 bottom-0 z-[3] w-3 bg-gradient-to-r from-zinc-950/[0.08] via-zinc-950/[0.025] to-transparent"
style={{ left: `${ACCOUNT_COL_WIDTH}px` }}
/>
<div
role="table"
aria-label="B2B SaaS accounts"
className="overflow-x-auto"
>
<TableHeaderRow sort={sort} onSort={handleSort} />
<div role="rowgroup">
<AnimatePresence initial={false}>
{visibleAccounts.map((account) => (
<AccountRow
key={account.id}
account={account}
selected={selectedId === account.id}
onSelect={(id) =>
setSelectedId((prev) => (prev === id ? null : id))
}
/>
))}
</AnimatePresence>
{visibleAccounts.length === 0 ? (
<div
className={cn(
"flex min-w-[1150px] items-center justify-center px-6 py-12 text-[13px] text-zinc-400",
SURFACE_GRAY,
)}
>
No accounts match the current filters.
</div>
) : null}
</div>
</div>
</div>
</div>
</div>
);
}
Update the import paths to match your project setup.
Resource details
PublishedApril 15, 2026
CategoryTable
ReactFramer MotionTailwind CSSPhosphor Icons
Resource details
PublishedApril 15, 2026
CategoryTable
ReactFramer MotionTailwind CSSPhosphor Icons