Update Plan Card
billingsdk/update-plan-cardFreeBlock
A update plan card component
Install it
npx shadcn@latest add https://billingsdk.com/r/update-plan-card.jsonSource
1"use client";23import { useState, useCallback } from "react";4import { motion, AnimatePresence } from "motion/react";5import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";6import { Button } from "@/components/ui/button";7import { Badge } from "@/components/ui/badge";8import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";9import { Toggle } from "@/components/ui/toggle";10import { Label } from "@/components/ui/label";11import { type Plan } from "@/lib/billingsdk-config";12import { cn } from "@/lib/utils";1314export interface UpdatePlanCardProps {15 currentPlan: Plan;16 plans: Plan[];17 onPlanChange: (planId: string) => void;18 className?: string;19 title?: string;20}2122const easing = [0.4, 0, 0.2, 1] as const;2324export function UpdatePlanCard({25 currentPlan,26 plans,27 onPlanChange,28 className,29 title,30}: UpdatePlanCardProps) {31 const [isYearly, setIsYearly] = useState(false);32 const [selectedPlan, setSelectedPlan] = useState<string | undefined>(33 undefined,34 );3536 const getCurrentPrice = useCallback(37 (plan: Plan) => (isYearly ? `${plan.yearlyPrice}` : `${plan.monthlyPrice}`),38 [isYearly],39 );4041 const handlePlanChange = useCallback((planId: string) => {42 setSelectedPlan((prev) => (prev === planId ? undefined : planId));43 }, []);4445 return (46 <Card47 className={cn(48 "mx-auto w-full max-w-xl overflow-hidden text-left shadow-lg",49 className,50 )}51 >52 <CardHeader className="flex flex-row items-center justify-between pb-2">53 <CardTitle className="text-base font-semibold">54 {title || "Upgrade Plan"}55 </CardTitle>56 <div className="flex items-center gap-2 text-sm">57 <Toggle58 size="sm"59 pressed={!isYearly}60 onPressedChange={(pressed) => setIsYearly(!pressed)}61 className="px-3"62 >63 Monthly64 </Toggle>65 <Toggle66 pressed={isYearly}67 onPressedChange={(pressed) => setIsYearly(pressed)}68 className="px-3"69 >70 Yearly71 </Toggle>72 </div>73 </CardHeader>74 <CardContent className="space-y-3">75 <RadioGroup value={selectedPlan} onValueChange={handlePlanChange}>76 <div className="space-y-2.5 sm:space-y-3">77 {plans.map((plan, index) => (78 <motion.div79 key={plan.id}80 layout81 initial={{ opacity: 0, y: 20 }}82// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from billingsdk
All 35 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| All Componentsall | billingsdk | Blocks | Free | no deps | |
| Top Bannerbanner | billingsdk | Blocks | Free | 2 deps · 2 files | |
| Billing Screenbilling-screen | billingsdk | Blocks | Free | 2 deps · 2 files | |
| Billing Settingsbilling-settings | billingsdk | Blocks | Free | 2 deps · 2 files | |
| Billing Settings 2billing-settings-2 | billingsdk | Blocks | Free | 1 dep · 2 files | |
| Cancel Subscription Cardcancel-subscription-card | billingsdk | Blocks | Free | 1 dep · 3 files | |
| Cancel Subscription Dialogcancel-subscription-dialog | billingsdk | Blocks | Free | 1 dep · 3 files | |
| Detailed Usage Tabledetailed-usage-table | billingsdk | Blocks | Free | no deps · 2 files |
