Pricing Card
A beautiful glassmorphism pricing card with nested card design and feature lists.
Category
CardReact
CSS
Tailwind
Manual
Create a file and paste the following code into it.
pricing-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
"use client";
import type { FC, ReactNode } from "react";
import Image from "next/image";
import { CheckmarkCircle02Icon, HugeiconsIcon } from "@/components/icons";
import { cn } from "@/lib/cn";
import { RaisedButton } from "@/registry/new-york/ui/raised-button";
export interface PricingFeature {
text: string;
icon?: ReactNode;
}
export interface PricingCardProps {
/** Plan title (e.g., "Free", "Pro", "Enterprise") */
title: string;
/** Price amount (e.g., 0, 9.99, 29) */
price: number;
/** Currency symbol (default: "$") */
currency?: string;
/** Original price before discount (shows strikethrough) */
originalPrice?: number;
/** Plan description/subtitle */
description?: string;
/** Features included in this plan */
features?: (string | PricingFeature)[];
/** Custom title above features list */
featuresTitle?: ReactNode;
/** Billing period: true for monthly, false for yearly */
isMonthly?: boolean;
/** Show "Current Plan" badge */
isCurrentPlan?: boolean;
/** Button label (default: "Get Started") */
buttonLabel?: string;
/** Button click handler */
onButtonClick?: () => void;
/** Whether button is disabled */
isDisabled?: boolean;
/** Whether button is in loading state */
isLoading?: boolean;
/** Accent color for button (CSS color value) */
accentColor?: string;
/** Background image URL */
backgroundImage?: string;
/** Additional CSS classes */
className?: string;
}
const formatPrice = (amount: number, currency: string): string => {
if (amount === 0) return `${currency}0`;
return `${currency}${amount.toFixed(amount % 1 === 0 ? 0 : 2)}`;
};
export const PricingCard: FC<PricingCardProps> = ({
title,
price,
currency = "$",
originalPrice,
description,
features,
featuresTitle,
isMonthly = true,
isCurrentPlan = false,
buttonLabel,
onButtonClick,
isDisabled = false,
isLoading = false,
accentColor = "#3b82f6",
backgroundImage,
className,
}) => {
const formattedPrice = formatPrice(price, currency);
const formattedOriginalPrice = originalPrice
? formatPrice(originalPrice, currency)
: null;
const getButtonLabel = (): string => {
if (isLoading) return "Loading...";
if (buttonLabel) return buttonLabel;
if (isCurrentPlan) return "Current Plan";
if (price === 0) return "Get Started";
return "Upgrade";
};
const isFree = price === 0;
const buttonBgColor = isFree ? "#3b3b3b" : accentColor;
return (
<div
className={cn(
"relative w-full overflow-hidden rounded-3xl",
"bg-zinc-100/80 dark:bg-zinc-900/50",
"backdrop-blur-sm",
className,
)}
>
{backgroundImage && (
<div className="absolute inset-0 z-0">
<Image
src={backgroundImage}
alt=""
fill
className="object-cover opacity-50 dark:opacity-30"
/>
<div className="absolute inset-0 bg-gradient-to-b from-transparent to-zinc-100/90 dark:to-zinc-900/90" />
</div>
)}
{/* Header Section */}
<div className="relative z-[1] flex flex-col gap-2 p-6 pb-4">
<div className="flex flex-row items-center justify-between">
<div className="flex items-center gap-2">
<span className="text-2xl font-semibold text-zinc-900 dark:text-white">
{title}
</span>
{isCurrentPlan && (
<span className="flex items-center gap-1 rounded-full bg-green-500/20 px-2 py-0.5 text-xs font-medium text-green-700 dark:text-green-400">
Current Plan
</span>
)}
</div>
</div>
</div>
{/* Inner Nested Card - Price & Button */}
<div className="relative z-[-1] mx-4 mb-4 flex flex-col gap-4 overflow-hidden rounded-3xl bg-white/80 dark:bg-black/70 p-6 shadow-xl backdrop-blur-2xl">
{/* Description */}
{description && (
<p className="text-sm leading-relaxed text-zinc-600 dark:text-zinc-200">
{description}
</p>
)}
{/* Price Section */}
<div className="relative z-[1] flex flex-col gap-0">
<div className="flex items-baseline gap-2">
{formattedOriginalPrice && !isMonthly && (
<span className="text-3xl font-normal text-red-500 line-through">
{formattedOriginalPrice}
</span>
)}
<span className="text-5xl font-bold text-zinc-900 dark:text-white">
{formattedPrice}
</span>
</div>
<span className="min-h-5 text-sm font-normal text-zinc-500 dark:text-zinc-400">
{price > 0 && (isMonthly ? "/ per month" : "/ per year")}
</span>
</div>
{/* Button Section */}
<div className="relative z-[1]">
<RaisedButton
onClick={onButtonClick}
disabled={isDisabled || isLoading || isCurrentPlan}
className="w-full rounded-xl text-base font-semibold h-12"
color={buttonBgColor}
>
{getButtonLabel()}
</RaisedButton>
</div>
</div>
{/* Features Section */}
{(featuresTitle || (features && features.length > 0)) && (
<div className="relative z-[1] flex flex-1 flex-col gap-2 px-6 pb-6">
{featuresTitle}
{features?.map((feature) => {
const featureText =
typeof feature === "string" ? feature : feature.text;
const featureIcon =
typeof feature === "object" && feature.icon ? (
feature.icon
) : (
<HugeiconsIcon
icon={CheckmarkCircle02Icon}
size={18}
className="text-green-600 dark:text-green-400"
/>
);
return (
<div
key={featureText}
className="flex items-center gap-3 text-sm font-light text-zinc-700 dark:text-zinc-300"
>
<span className="flex-shrink-0">{featureIcon}</span>
{featureText}
</div>
);
})}
</div>
)}
</div>
);
};
export default PricingCard;
Update the import paths to match your project setup.