opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Dashboard
  4. Recent Transactions Card
Back to Dashboard

Components / Dashboard

Recent Transactions Card

Free Dashboard React component — RecentTransactionsCard. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Recent transactions feed with merchant avatars, categories, income markers, and row actions.

Preview

Recent transactions

  • Spotify

    Spotify

    − $50.24

    07 Feb, 11:18 AMSubscription
  • Billa

    Billa

    − $51.68

    07 Feb, 11:18 AMFood & Drinks
  • Starbucks

    Starbucks

    − $51.68

    07 Feb, 11:18 AMFood & Drinks
  • Upwork

    Upwork

    $250.00

    07 Feb, 11:18 AMIncome
  • Netflix

    Netflix

    − $51.68

    07 Feb, 11:18 AMEntertainment

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/dashboard/recent-transactions-card.tsx in your project.

  4. 4

    Import and render:

    Example

    import { RecentTransactionsCard } from "@/components/dashboard/recent-transactions-card";

    <RecentTransactionsCard items={[{ id: "1", merchant: "Spotify", category: "Subscription", amount: "$50.24", time: "07 Feb" }]} />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/dashboard/recent-transactions-card.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
"use client";
 
import { forwardRef, type ComponentPropsWithoutRef } from "react";
 
import Image from "next/image";
import Link from "next/link";
 
import {
ArrowDownRight,
ArrowUpRight,
MoreVertical,
Search,
} from "lucide-react";
 
import { cn } from "@/lib/cn";
 
export type RecentTransactionItem = Readonly<{
id: string;
merchant: string;
category: string;
amount: string;
time: string;
income?: boolean;
logo?: string;
logoAlt?: string;
}>;
 
export type RecentTransactionsCardProps = Readonly<
{
title?: string;
items?: readonly RecentTransactionItem[];
viewAllHref?: string;
viewAllLabel?: string;
onSearch?: () => void;
onItemMenu?: (id: string) => void;
} & ComponentPropsWithoutRef<"article">
>;
 
const DEFAULT_ITEMS: readonly RecentTransactionItem[] = [
{
id: "1",
merchant: "Spotify",
category: "Subscription",
amount: "$50.24",
time: "07 Feb, 11:18 AM",
logo: "/profile-picture.png",
},
{
id: "2",
merchant: "Billa",
category: "Food & Drinks",
amount: "$51.68",
time: "07 Feb, 11:18 AM",
logo: "/woman.png",
},
{
id: "3",
merchant: "Starbucks",
category: "Food & Drinks",
amount: "$51.68",
time: "07 Feb, 11:18 AM",
logo: "/profile-picture.png",
},
{
id: "4",
merchant: "Upwork",
category: "Income",
amount: "$250.00",
time: "07 Feb, 11:18 AM",
income: true,
logo: "/woman.png",
},
{
id: "5",
merchant: "Netflix",
category: "Entertainment",
amount: "$51.68",
time: "07 Feb, 11:18 AM",
logo: "/profile-picture.png",
},
];
 
function MerchantMark({
item,
}: Readonly<{ item: RecentTransactionItem }>) {
const initial = item.merchant.charAt(0).toUpperCase();
 
return (
<div className="relative shrink-0">
<div className="relative size-10 overflow-hidden rounded-full bg-neutral-100">
{item.logo ? (
<Image
src={item.logo}
alt={item.logoAlt ?? item.merchant}
fill
sizes="40px"
className="object-cover"
/>
) : (
<span className="flex size-full items-center justify-center text-sm font-semibold text-neutral-600">
{initial}
</span>
)}
</div>
<span
className={cn(
"absolute -right-0.5 -bottom-0.5 flex size-4 items-center justify-center rounded-full text-white",
item.income ? "bg-emerald-500" : "bg-red-500",
)}
>
{item.income ? (
<ArrowUpRight size={10} aria-hidden />
) : (
<ArrowDownRight size={10} aria-hidden />
)}
</span>
</div>
);
}
 
// Recent transactions card — finance feed with categories and income markers.
export const RecentTransactionsCard = forwardRef<
HTMLElement,
RecentTransactionsCardProps
>(
(
{
className,
title = "Recent transactions",
items = DEFAULT_ITEMS,
viewAllHref = "#",
viewAllLabel = "View all",
onSearch,
onItemMenu,
...props
},
ref,
) => (
<article
ref={ref}
data-slot="recent-transactions-card"
className={cn(
"w-md rounded-3xl border border-neutral-100 bg-white p-5 font-sans shadow-lg shadow-black/5",
className,
)}
{...props}
>
<header className="mb-4 flex items-center justify-between gap-3">
<h2 className="text-base font-semibold text-neutral-900">{title}</h2>
<div className="flex items-center gap-2">
<button
type="button"
aria-label="Search transactions"
onClick={onSearch}
className="flex size-7 items-center justify-center rounded-full border border-neutral-200 text-neutral-600 transition-colors hover:bg-neutral-50"
>
<Search size={15} aria-hidden />
</button>
{viewAllHref && viewAllHref !== "#" ? (
<Link
href={viewAllHref}
className="rounded-full border border-neutral-200 px-3 py-1.5 text-xs font-medium text-neutral-700 transition-colors hover:bg-neutral-50"
>
{viewAllLabel}
</Link>
) : (
<button
type="button"
className="rounded-full border border-neutral-200 px-3 py-1.5 text-xs font-medium text-neutral-700 transition-colors hover:bg-neutral-50"
>
{viewAllLabel}
</button>
)}
</div>
</header>
 
<ul className="space-y-3">
{items.length === 0 ? (
<li className="py-8 text-center text-sm text-neutral-500">
No transactions yet.
</li>
) : (
items.map((item) => (
<li
key={item.id}
className="flex items-center gap-3 rounded-full px-1 py-1 transition-colors hover:bg-neutral-50"
>
<MerchantMark item={item} />
 
<div className="min-w-0 flex-1">
<div className="flex items-center justify-between gap-2">
<p className="truncate text-sm font-medium text-neutral-900">
{item.merchant}
</p>
<p
className={cn(
"shrink-0 text-sm font-semibold tabular-nums",
item.income ? "text-emerald-600" : "text-neutral-900",
)}
>
{item.income ? item.amount : `− ${item.amount}`}
</p>
</div>
<div className="mt-1 flex items-center justify-between gap-2">
<span className="truncate text-[11px] text-neutral-400">
{item.time}
</span>
<span className="shrink-0 rounded-full border border-neutral-200 px-2 py-0.5 text-[10px] text-neutral-500">
{item.category}
</span>
</div>
</div>
 
<button
type="button"
aria-label={`More options for ${item.merchant}`}
onClick={() => onItemMenu?.(item.id)}
className="flex size-8 shrink-0 items-center justify-center rounded-full text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700"
>
<MoreVertical size={14} aria-hidden />
</button>
</li>
))
)}
</ul>
</article>
),
);
 
RecentTransactionsCard.displayName = "RecentTransactionsCard";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/dashboard/recent-transactions-card.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.