All blocks
[11] Marketing
Pricing With Billing Switch
A monthly and yearly switch over three plan cards, changing every price and the billing line under it.
1280px
Copy the code
One file with one component and its sample data. It needs @vaneui/ui and its stylesheet, set up as in the installation guide. It passes an onChange handler, so in the Next.js App Router add "use client" at the top of its file.
pricing-toggle.tsx
import { useState } from "react";import { Badge, Button, Card, Col, Container, List, ListItem, PageTitle, Row, Section, SegmentedControl, SegmentedControlItem, Text, Title } from "@vaneui/ui";
type Billing = "monthly" | "yearly";
const plans = [ { name: "Starter", monthly: 0, yearly: 0, note: "For trying it out", features: ["1 project", "Community support"], href: "/signup?plan=starter" }, { name: "Pro", monthly: 12, yearly: 10, note: "For one person shipping", features: ["Unlimited projects", "Custom domains", "Email support"], href: "/signup?plan=pro", popular: true }, { name: "Team", monthly: 40, yearly: 32, note: "For teams of up to 10", features: ["Everything in Pro", "Shared workspaces", "Roles and permissions", "Priority support"], href: "/signup?plan=team" },];
export function PricingToggle() { const [billing, setBilling] = useState<Billing>("yearly");
return ( <Section> <Container itemsStretch> <Col lg> <Col itemsCenter> <Col xs itemsCenter> <PageTitle textCenter>Pricing</PageTitle> <Text secondary textCenter>Start free. Pay yearly and get two months for free.</Text> </Col> <Row sm flexWrap justifyCenter> <SegmentedControl aria-label="Billing period" value={billing} onChange={(e) => setBilling(e.target.value as Billing)}> <SegmentedControlItem value="monthly">Monthly</SegmentedControlItem> <SegmentedControlItem value="yearly">Yearly</SegmentedControlItem> </SegmentedControl> <Badge success>Save 20% yearly</Badge> </Row> </Col> <Row mobileStack itemsStretch> {plans.map((p) => { const price = billing === "yearly" ? p.yearly : p.monthly; return ( <Card key={p.name} flex1 strongBorder={p.popular}> <Row justifyBetween> <Title>{p.name}</Title> {p.popular && <Badge filled>Most popular</Badge>} </Row> <Col noGap> <Row xs itemsBaseline> <Text xl fontBold className="tabular-nums">${price}</Text> <Text sm secondary>per month</Text> </Row> <Text xs tertiary className="tabular-nums"> {price === 0 ? "Free forever" : billing === "yearly" ? `$${price * 12} billed yearly` : "Billed monthly"} </Text> </Col> <Text sm secondary>{p.note}</Text> <Col flex1> <List> {p.features.map((f) => <ListItem key={f}>{f}</ListItem>)} </List> </Col> <Button href={p.href} filled={p.popular} md wFull>Choose {p.name}</Button> </Card> ); })} </Row> </Col> </Container> </Section> );}Components in this block
Adapt it with your coding agent
Add the VaneUI MCP server, and your agent reads the component docs and prop tables while it changes the block: the copy, the sample data or the layout.
$ claude mcp add vaneui -- npx -y @vaneui/mcp
Setup for other editors is in the AI assistants guide.