مقایسهٔ پلنها
پیشنمایش تمامصفحهقیمتگذاری با جدولِ مقایسهٔ کامل: نام، قیمت و دکمهٔ هر پلن در سرِ ستون، قابلیتها در گروههای جدا با تیک و خط، ستونِ پیشنهادی با زمینهٔ ملایم، دورهٔ ماهانه یا سالانه با تب.
۱. نصب کامپوننتها
این بلاک از ۷ آیتم دیگ استفاده میکند: badgebuttoncontrol-sizeiconspersiantabletoggle-group
npx digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toggle-group.jsonpnpm dlx digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toggle-group.jsonyarn dlx digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toggle-group.jsonbunx --bun digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toggle-group.jsonnpx digdesign@latest add badge button control-size persian table toggle-group --framework vuepnpm dlx digdesign@latest add badge button control-size persian table toggle-group --framework vueyarn dlx digdesign@latest add badge button control-size persian table toggle-group --framework vuebunx --bun digdesign@latest add badge button control-size persian table toggle-group --framework vuenpx digdesign@latest add button --framework sveltepnpm dlx digdesign@latest add button --framework svelteyarn dlx digdesign@latest add button --framework sveltebunx --bun digdesign@latest add button --framework sveltenpx digdesign@latest add badge button control-size icons persian table toggle-group utils --framework angularpnpm dlx digdesign@latest add badge button control-size icons persian table toggle-group utils --framework angularyarn dlx digdesign@latest add badge button control-size icons persian table toggle-group utils --framework angularbunx --bun digdesign@latest add badge button control-size icons persian table toggle-group utils --framework angularnpx digdesign@latest add badge button control-size persian table toggle-group --framework androidpnpm dlx digdesign@latest add badge button control-size persian table toggle-group --framework androidyarn dlx digdesign@latest add badge button control-size persian table toggle-group --framework androidbunx --bun digdesign@latest add badge button control-size persian table toggle-group --framework android۲. کد صفحه
کد را در صفحهٔ پروژهتان بگذارید (React: app/<route>/page.tsx) و متنها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریمورک کدِ همین صفحه در فریمورک دیگر را ببینید.
"use client"
import * as React from "react"
import { CheckIcon, MinusIcon } from "@/components/icons"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { formatNumber } from "@/lib/persian"
const PLANS = [
{ id: "basic", title: "پایه", monthly: 0, note: "برای شروع" },
{ id: "pro", title: "حرفهای", monthly: 490_000, note: "برای تیمهای کوچک", featured: true },
{ id: "team", title: "سازمانی", monthly: 1_900_000, note: "برای سازمانها" },
] as const
type Value = boolean | string
/** هر ردیف: یک قابلیت و مقدارش برای هر پلن (true، false یا متن). */
const GROUPS: { title: string; rows: { label: string; values: [Value, Value, Value] }[] }[] = [
{
title: "پایه",
rows: [
{ label: "پروژه", values: ["۱", "۱۰", "نامحدود"] },
{ label: "عضوِ تیم", values: ["۱", "۵", "نامحدود"] },
{ label: "فضای ذخیرهسازی", values: ["۵۰۰ مگابایت", "۲۰ گیگابایت", "نامحدود"] },
],
},
{
title: "گزارش و تحلیل",
rows: [
{ label: "گزارشِ ماهانه", values: [true, true, true] },
{ label: "داشبوردِ سفارشی", values: [false, true, true] },
{ label: "خروجی اکسل و API", values: [false, true, true] },
{ label: "گزارشِ پیشرفته", values: [false, false, true] },
],
},
{
title: "امنیت و پشتیبانی",
rows: [
{ label: "ورودِ دومرحلهای", values: [true, true, true] },
{ label: "ورودِ یکپارچه (SSO)", values: [false, false, true] },
{ label: "پشتیبانی", values: ["ایمیل", "ویژه", "اختصاصی، ۲۴ ساعته"] },
],
},
]
function Mark({ value }: { value: Value }) {
if (typeof value === "string") return <span className="text-sm font-medium">{value}</span>
return value ? (
<CheckIcon aria-label="دارد" className="mx-auto size-5 text-success-subtle-foreground" />
) : (
<MinusIcon aria-label="ندارد" className="mx-auto size-5 text-muted-foreground" />
)
}
/**
* قیمتگذاری با جدولِ مقایسه: نام و قیمت و دکمهٔ هر پلن در سرِ ستون، قابلیتها در
* گروههای جدا، و ستونِ پیشنهادی با زمینهٔ ملایم و برچسب. در موبایل جدول افقی اسکرول
* میخورد و ستونِ قابلیت ثابت میماند.
*/
export default function PricingCompareBlock() {
const [period, setPeriod] = React.useState("monthly")
const yearly = period === "yearly"
// ستونِ پیشنهادی با زمینهٔ primary-subtle و نوارِ بالاییِ پررنگ مشخص است، نه برچسبِ بنفش؛ همهٔ ستونها با خطِ عمودی جدا.
const featuredCell = "bg-primary-subtle"
const planCell = "border-s border-border"
return (
<ControlSizeProvider size="xl" asChild>
<main className="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-16 sm:px-6">
<header className="flex flex-col items-center gap-6 text-center">
<div className="flex flex-col items-center gap-3">
<Badge variant="soft">تعرفهها</Badge>
<h1 className="text-4xl leading-snug font-black sm:text-5xl">مقایسهٔ کاملِ پلنها</h1>
<p className="max-w-xl text-lg leading-8 text-muted-foreground">همهٔ قابلیتها کنارِ هم؛ ۱۴ روز رایگان امتحان کنید.</p>
</div>
<ControlSizeProvider size="lg" mobileSize="default" asChild>
<ToggleGroup type="single" variant="segmented" value={period} onValueChange={(value) => value && setPeriod(value as string)} aria-label="دورهٔ پرداخت">
<ToggleGroupItem value="monthly">ماهانه</ToggleGroupItem>
<ToggleGroupItem value="yearly">سالانه · ۲ ماه رایگان</ToggleGroupItem>
</ToggleGroup>
</ControlSizeProvider>
</header>
<div>
<Table layout="fixed" className="min-w-[44rem]">
<TableHeader>
<TableRow className="hover:bg-card">
<TableHead className="w-[28%] align-bottom">
<span className="sr-only">قابلیت</span>
</TableHead>
{PLANS.map((plan) => (
<TableHead key={plan.id} className={`h-auto py-6 text-center align-top ${planCell} ${"featured" in plan ? `${featuredCell} border-t-4 border-t-primary` : "border-t-4 border-t-transparent"}`}>
<div className="flex flex-col items-center gap-2">
{/* جای برچسب در همهٔ ستونها رزرو است تا عنوانها همتراز بمانند. */}
<span className="flex h-6 items-center">{"featured" in plan && <Badge variant="soft" color="default">پیشنهادِ ما</Badge>}</span>
<span className="text-base font-bold text-foreground">{plan.title}</span>
<span className="text-xs font-normal text-muted-foreground">{plan.note}</span>
<span className="mt-2 text-2xl font-black text-foreground tabular-nums">
{plan.monthly === 0 ? "رایگان" : formatNumber(yearly ? plan.monthly * 10 : plan.monthly)}
</span>
<span className="text-xs font-normal text-muted-foreground">
{plan.monthly === 0 ? "برای همیشه" : yearly ? "تومان / سال" : "تومان / ماه"}
</span>
<Button fullWidth variant={"featured" in plan ? "default" : "outline"} className="mt-4">
{plan.monthly === 0 ? "شروع رایگان" : `انتخاب ${plan.title}`}
</Button>
</div>
</TableHead>
))}
</TableRow>
</TableHeader>
{GROUPS.map((group) => (
<TableBody key={group.title}>
<TableRow className="hover:bg-card">
<TableCell colSpan={4} className="bg-muted text-sm font-bold">
{group.title}
</TableCell>
</TableRow>
{group.rows.map((row) => (
<TableRow key={row.label}>
<TableCell className="text-sm text-muted-foreground">{row.label}</TableCell>
{row.values.map((value, index) => (
<TableCell key={PLANS[index].id} className={`text-center ${planCell} ${"featured" in PLANS[index] ? featuredCell : ""}`}>
<Mark value={value} />
</TableCell>
))}
</TableRow>
))}
</TableBody>
))}
</Table>
</div>
<p className="text-center text-sm text-muted-foreground">
پلنِ سازمانی سفارشی لازم دارید�?{" "}
<Button variant="link" className="h-auto p-0">
با فروش صحبت کنید
</Button>
</p>
</main>
</ControlSizeProvider>
)
}
<script setup lang="ts">
import { ref } from "vue"
import Badge from "@/components/ui/Badge.vue"
import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Table from "@/components/ui/Table.vue"
import TableBody from "@/components/ui/TableBody.vue"
import TableCell from "@/components/ui/TableCell.vue"
import TableHead from "@/components/ui/TableHead.vue"
import TableHeader from "@/components/ui/TableHeader.vue"
import TableRow from "@/components/ui/TableRow.vue"
import ToggleGroup from "@/components/ui/ToggleGroup.vue"
import ToggleGroupItem from "@/components/ui/ToggleGroupItem.vue"
import { DigIcon } from "@/lib/icons"
import { formatNumber } from "@/lib/persian"
type PlanItem = { id: string; title: string; monthly: number; note: string; featured?: boolean }
const PLANS: PlanItem[] = [
{ id: "basic", title: "پایه", monthly: 0, note: "برای شروع" },
{ id: "pro", title: "حرفهای", monthly: 490_000, note: "برای تیمهای کوچک", featured: true },
{ id: "team", title: "سازمانی", monthly: 1_900_000, note: "برای سازمانها" },
]
type Value = boolean | string
/** هر ردیف: یک قابلیت و مقدارش برای هر پلن (true، false یا متن). */
const GROUPS: { title: string; rows: { label: string; values: [Value, Value, Value] }[] }[] = [
{
title: "پایه",
rows: [
{ label: "پروژه", values: ["۱", "۱۰", "نامحدود"] },
{ label: "عضوِ تیم", values: ["۱", "۵", "نامحدود"] },
{ label: "فضای ذخیرهسازی", values: ["۵۰۰ مگابایت", "۲۰ گیگابایت", "نامحدود"] },
],
},
{
title: "گزارش و تحلیل",
rows: [
{ label: "گزارشِ ماهانه", values: [true, true, true] },
{ label: "داشبوردِ سفارشی", values: [false, true, true] },
{ label: "خروجی اکسل و API", values: [false, true, true] },
{ label: "گزارشِ پیشرفته", values: [false, false, true] },
],
},
{
title: "امنیت و پشتیبانی",
rows: [
{ label: "ورودِ دومرحلهای", values: [true, true, true] },
{ label: "ورودِ یکپارچه (SSO)", values: [false, false, true] },
{ label: "پشتیبانی", values: ["ایمیل", "ویژه", "اختصاصی، ۲۴ ساعته"] },
],
},
]
const period = ref("monthly")
// ستونِ پیشنهادی با زمینهٔ primary-subtle و نوارِ بالاییِ پررنگ مشخص است، نه برچسبِ بنفش؛ همهٔ ستونها با خطِ عمودی جدا.
const featuredCell = "bg-primary-subtle"
const planCell = "border-s border-border"
function onPeriod(value: string | string[] | undefined) {
if (value) period.value = value as string
}
</script>
<template>
<ControlSize size="xl" as-child>
<main class="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-16 sm:px-6">
<header class="flex flex-col items-center gap-6 text-center">
<div class="flex flex-col items-center gap-3">
<Badge variant="soft">تعرفهها</Badge>
<h1 class="text-4xl leading-snug font-black sm:text-5xl">مقایسهٔ کاملِ پلنها</h1>
<p class="max-w-xl text-lg leading-8 text-muted-foreground">همهٔ قابلیتها کنارِ هم؛ ۱۴ روز رایگان امتحان کنید.</p>
</div>
<ControlSize size="lg" mobile-size="default" as-child>
<ToggleGroup type="single" variant="segmented" :value="period" aria-label="دورهٔ پرداخت" @update:value="onPeriod">
<ToggleGroupItem value="monthly">ماهانه</ToggleGroupItem>
<ToggleGroupItem value="yearly">سالانه · ۲ ماه رایگان</ToggleGroupItem>
</ToggleGroup>
</ControlSize>
</header>
<div>
<Table layout="fixed" class="min-w-[44rem]">
<TableHeader>
<TableRow class="hover:bg-card">
<TableHead class="w-[28%] align-bottom">
<span class="sr-only">قابلیت</span>
</TableHead>
<TableHead
v-for="plan in PLANS"
:key="plan.id"
:class="`h-auto py-6 text-center align-top ${planCell} ${plan.featured ? `${featuredCell} border-t-4 border-t-primary` : 'border-t-4 border-t-transparent'}`"
>
<div class="flex flex-col items-center gap-2">
<!-- جای برچسب در همهٔ ستونها رزرو است تا عنوانها همتراز بمانند. -->
<span class="flex h-6 items-center"><Badge v-if="plan.featured" variant="soft" color="default">پیشنهادِ ما</Badge></span>
<span class="text-base font-bold text-foreground">{{ plan.title }}</span>
<span class="text-xs font-normal text-muted-foreground">{{ plan.note }}</span>
<span class="mt-2 text-2xl font-black text-foreground tabular-nums">
{{ plan.monthly === 0 ? "رایگان" : formatNumber(period === "yearly" ? plan.monthly * 10 : plan.monthly) }}
</span>
<span class="text-xs font-normal text-muted-foreground">
{{ plan.monthly === 0 ? "برای همیشه" : period === "yearly" ? "تومان / سال" : "تومان / ماه" }}
</span>
<Button full-width :variant="plan.featured ? 'default' : 'outline'" class="mt-4">
{{ plan.monthly === 0 ? "شروع رایگان" : `انتخاب ${plan.title}` }}
</Button>
</div>
</TableHead>
</TableRow>
</TableHeader>
<TableBody v-for="group in GROUPS" :key="group.title">
<TableRow class="hover:bg-card">
<TableCell :colspan="4" class="bg-muted text-sm font-bold">{{ group.title }}</TableCell>
</TableRow>
<TableRow v-for="row in group.rows" :key="row.label">
<TableCell class="text-sm text-muted-foreground">{{ row.label }}</TableCell>
<TableCell v-for="(value, index) in row.values" :key="PLANS[index].id" :class="`text-center ${planCell} ${PLANS[index].featured ? featuredCell : ''}`">
<span v-if="typeof value === 'string'" class="text-sm font-medium">{{ value }}</span>
<DigIcon v-else-if="value" name="check" aria-label="دارد" class="mx-auto size-5 text-success-subtle-foreground" />
<DigIcon v-else name="minus" aria-label="ندارد" class="mx-auto size-5 text-muted-foreground" />
</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
<p class="text-center text-sm text-muted-foreground">
پلنِ سازمانی سفارشی لازم دارید؟
<Button variant="link" class="h-auto p-0">با فروش صحبت کنید</Button>
</p>
</main>
</ControlSize>
</template>
کدِ این بلاک هنوز برای Svelte نوشته نشده است.
این موارد هنوز برای Svelte آماده نیستند: badgecontrol-sizepersiantabletoggle-groupآیکون checkآیکون minus
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننتهای Svelte میسازد.
import { ChangeDetectionStrategy, Component, signal } from "@angular/core"
import { DigIcon } from "@/lib/icons"
import { formatNumber } from "@/lib/persian"
import { cn } from "@/lib/utils"
import { DigBadge } from "@/components/ui/badge"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import {
DigTable,
DigTableBody,
DigTableCell,
DigTableHead,
DigTableHeader,
DigTableRow,
} from "@/components/ui/table"
import {
DigToggleGroup,
DigToggleGroupItem,
} from "@/components/ui/toggle-group"
type PlanItem = {
id: string
title: string
monthly: number
note: string
featured?: boolean
}
const PLANS: PlanItem[] = [
{ id: "basic", title: "پایه", monthly: 0, note: "برای شروع" },
{
id: "pro",
title: "حرفهای",
monthly: 490_000,
note: "برای تیمهای کوچک",
featured: true,
},
{ id: "team", title: "سازمانی", monthly: 1_900_000, note: "برای سازمانها" },
]
type Value = boolean | string
const GROUPS: {
title: string
rows: { label: string; values: [Value, Value, Value] }[]
}[] = [
{
title: "پایه",
rows: [
{ label: "پروژه", values: ["۱", "۱۰", "نامحدود"] },
{ label: "عضوِ تیم", values: ["۱", "۵", "نامحدود"] },
{
label: "فضای ذخیرهسازی",
values: ["۵۰۰ مگابایت", "۲۰ گیگابایت", "نامحدود"],
},
],
},
{
title: "گزارش و تحلیل",
rows: [
{ label: "گزارشِ ماهانه", values: [true, true, true] },
{ label: "داشبوردِ سفارشی", values: [false, true, true] },
{ label: "خروجی اکسل و API", values: [false, true, true] },
{ label: "گزارشِ پیشرفته", values: [false, false, true] },
],
},
{
title: "امنیت و پشتیبانی",
rows: [
{ label: "ورودِ دومرحلهای", values: [true, true, true] },
{ label: "ورودِ یکپارچه (SSO)", values: [false, false, true] },
{ label: "پشتیبانی", values: ["ایمیل", "ویژه", "اختصاصی، ۲۴ ساعته"] },
],
},
]
@Component({
selector: "dig-block-pricing-compare",
imports: [
DigBadge,
DigButton,
DigControlSize,
DigIcon,
DigTable,
DigTableBody,
DigTableCell,
DigTableHead,
DigTableHeader,
DigTableRow,
DigToggleGroup,
DigToggleGroupItem,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<main
digControlSize="xl"
class="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-16 sm:px-6"
>
<header class="flex flex-col items-center gap-6 text-center">
<div class="flex flex-col items-center gap-3">
<span digBadge variant="soft">تعرفهها</span>
<h1 class="text-4xl leading-snug font-black sm:text-5xl">
مقایسهٔ کاملِ پلنها
</h1>
<p class="max-w-xl text-lg leading-8 text-muted-foreground">
همهٔ قابلیتها کنارِ هم؛ ۱۴ روز رایگان امتحان کنید.
</p>
</div>
<div digControlSize="lg" mobileSize="default">
<div
digToggleGroup
type="single"
variant="segmented"
[value]="period()"
aria-label="دورهٔ پرداخت"
(valueChange)="onPeriod($event)"
>
<button digToggleGroupItem type="button" value="monthly">
ماهانه
</button>
<button digToggleGroupItem type="button" value="yearly">
سالانه · ۲ ماه رایگان
</button>
</div>
</div>
</header>
<div>
<dig-table layout="fixed" class="min-w-[44rem]">
<thead digTableHeader>
<tr digTableRow class="hover:bg-card">
<th digTableHead class="w-[28%] align-bottom">
<span class="sr-only">قابلیت</span>
</th>
@for (plan of PLANS; track plan.id) {
<th
digTableHead
[class]="
cn(
'h-auto py-6 text-center align-top',
planCell,
plan.featured
? featuredCell + ' border-t-4 border-t-primary'
: 'border-t-4 border-t-transparent'
)
"
>
<div class="flex flex-col items-center gap-2">
<!-- جای برچسب در همهٔ ستونها رزرو است تا عنوانها همتراز بمانند. -->
<span class="flex h-6 items-center">
@if (plan.featured) {
<span digBadge variant="soft" color="default"
>پیشنهادِ ما</span
>
}
</span>
<span class="text-base font-bold text-foreground">{{
plan.title
}}</span>
<span class="text-xs font-normal text-muted-foreground">{{
plan.note
}}</span>
<span
class="mt-2 text-2xl font-black text-foreground tabular-nums"
>
{{
plan.monthly === 0
? "رایگان"
: formatNumber(
period() === "yearly"
? plan.monthly * 10
: plan.monthly
)
}}
</span>
<span class="text-xs font-normal text-muted-foreground">
{{
plan.monthly === 0
? "برای همیشه"
: period() === "yearly"
? "تومان / سال"
: "تومان / ماه"
}}
</span>
<button
digButton
type="button"
fullWidth
[variant]="plan.featured ? 'default' : 'outline'"
class="mt-4"
>
{{
plan.monthly === 0
? "شروع رایگان"
: \`انتخاب \${plan.title}\`
}}
</button>
</div>
</th>
}
</tr>
</thead>
@for (group of GROUPS; track group.title) {
<tbody digTableBody>
<tr digTableRow class="hover:bg-card">
<td
digTableCell
[colSpan]="4"
class="bg-muted text-sm font-bold"
>
{{ group.title }}
</td>
</tr>
@for (row of group.rows; track row.label) {
<tr digTableRow>
<td digTableCell class="text-sm text-muted-foreground">
{{ row.label }}
</td>
@for (value of row.values; track $index; let index = $index) {
<td
digTableCell
[class]="
'text-center ' +
planCell +
' ' +
(PLANS[index].featured ? featuredCell : '')
"
>
@if (typeof value === "string") {
<span class="text-sm font-medium">{{ value }}</span>
} @else if (value) {
<svg
digIcon="check"
aria-label="دارد"
class="mx-auto size-5 text-success-subtle-foreground"
></svg>
} @else {
<svg
digIcon="minus"
aria-label="ندارد"
class="mx-auto size-5 text-muted-foreground"
></svg>
}
</td>
}
</tr>
}
</tbody>
}
</dig-table>
</div>
<p class="text-center text-sm text-muted-foreground">
پلنِ سازمانی سفارشی لازم دارید؟
<button digButton type="button" variant="link" class="h-auto p-0">
با فروش صحبت کنید
</button>
</p>
</main>
`,
})
export class PricingCompareBlock {
readonly PLANS = PLANS
readonly GROUPS = GROUPS
readonly formatNumber = formatNumber
readonly cn = cn
readonly period = signal("monthly")
readonly featuredCell = "bg-primary-subtle"
readonly planCell = "border-s border-border"
onPeriod(value: string | string[] | undefined) {
if (value === "monthly" || value === "yearly") this.period.set(value)
}
}
کدِ این بلاک هنوز برای Android نوشته نشده است.
همهٔ کامپوننتهای لازم برای Android آمادهاند؛ با MCP میتوانید همین صفحه را از روی نسخهٔ React بسازید.
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننتهای Android میسازد.