# Cancel Subscription Card URL: /docs/components/cancel-subscription/cancel-subscription-card The Cancel Subscription Card component provides a comprehensive and user-friendly interface for handling subscription cancellations. It features a two-step confirmation process, loading states, error handling, and full customization options. *** title: Cancel Subscription Card description: The Cancel Subscription Card component provides a comprehensive and user-friendly interface for handling subscription cancellations. It features a two-step confirmation process, loading states, error handling, and full customization options. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ```tsx title="src/components/cancel-subscription-card-demo.tsx" "use client"; import { CancelSubscriptionCard } from "@/components/billingsdk/cancel-subscription-card"; import { plans } from "@/lib/billingsdk-config"; export function CancelSubscriptionCardDemo() { return (
{ console.log("Cancelling subscription for plan:", planId); return new Promise((resolve) => { setTimeout(() => { resolve(void 0); }, 1000); }); }} onKeepSubscription={async (planId) => { console.log("Keeping subscription for plan:", planId); }} className="max-w-4xl" />
); } ```
## Installation ```bash npx shadcn@latest add @billingsdk/cancel-subscription-card ``` ```bash pnpm dlx shadcn@latest add @billingsdk/cancel-subscription-card ``` ```bash yarn dlx shadcn@latest add @billingsdk/cancel-subscription-card ``` ```bash bunx shadcn@latest add @billingsdk/cancel-subscription-card ``` ```bash npx @billingsdk/cli add cancel-subscription-card ``` ```bash pnpm dlx @billingsdk/cli add cancel-subscription-card ``` ```bash yarn dlx @billingsdk/cli add cancel-subscription-card ``` ```bash bunx @billingsdk/cli add cancel-subscription-card ``` ## Usage ```tsx import { CancelSubscriptionCard } from "@/components/billingsdk/cancel-subscription-card"; import { plans } from "@/lib/billingsdk-config"; ``` ```tsx { // Handle cancellation await cancelSubscription(planId); }} /> ``` ## Props | Prop | Type | Required | Description | | -------------------- | ------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------ | | `title` | `string` | ✅ | Main card title | | `description` | `string` | ✅ | Card description text | | `plan` | `Plan` | ✅ | Plan object containing subscription details. The `plans` array in the `lib/billingsdk-config.ts` file. | | `onCancel` | `(planId: string) => Promise \| void` | ✅ | Callback when subscription is cancelled | | `leftPanelImageUrl` | `string` | ❌ | Background image URL for left panel | | `warningTitle` | `string` | ❌ | Title for warning section | | `warningText` | `string` | ❌ | Warning message text | | `keepButtonText` | `string` | ❌ | Text for keep subscription button | | `continueButtonText` | `string` | ❌ | Text for continue cancellation button | | `finalTitle` | `string` | ❌ | Title for final confirmation step | | `finalSubtitle` | `string` | ❌ | Subtitle for final confirmation step | | `finalWarningText` | `string` | ❌ | Final warning message | | `goBackButtonText` | `string` | ❌ | Text for go back button | | `confirmButtonText` | `string` | ❌ | Text for final confirm button | | `onKeepSubscription` | `(planId: string) => Promise \| void` | ❌ | Callback when user keeps subscription | | `className` | `string` | ❌ | Additional CSS classes | ## Theming The cancel subscription card component is styled using the `shadcn/ui` library. You can customize the colors and fonts by overriding the CSS variables. You can also get the theme from the [Theming](/docs/theming) page. ## Example ```tsx title="src/components/cancel-subscription-card-demo.tsx" "use client"; import { CancelSubscriptionCard } from "@/components/billingsdk/cancel-subscription-card"; import { plans } from "@/lib/billingsdk-config"; export function CancelSubscriptionCardDemo() { return (
{ console.log("Cancelling subscription for plan:", planId); return new Promise((resolve) => { setTimeout(() => { resolve(void 0); }, 1000); }); }} onKeepSubscription={async (planId) => { console.log("Keeping subscription for plan:", planId); }} className="max-w-4xl" />
); } ```