用法
import { LandingPricing } from './LandingPricing.jsx'
// Without onChoose a plan starts after a short wait. Wire it to your checkout:
<LandingPricing
locale="en"
currency="USD"
plans={plans} // [{ id, name, monthly, yearly, limit, people, points, featured? }]
compare={featureRows} // [{ name, values: [true | false | string per plan] }]
unit={['brew', 'brews']} // what the finder counts; a plan's limit is in it
steps={[10, 30, 100, 300]} // where the slider stops
finder={{ lead: 'Each month I brew', label: 'Brews a month', shared: 'For a café team', people: 3 }}
billing="yearly"
loading={!plans}
error={pricesError}
onRetry={reloadPrices}
onChoose={async (planId, billing) => (await startTrial(planId, billing)).ok}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字、示例方案和价格的语言。 |
plans | Array<{ id, name, monthly, yearly, limit: number | null, people, points: string[], featured? }> | sample plans | 按顺序排列的方案。价格按月计;`limit`(按小工具的单位,null 表示不限;旧名 `plants`)和 `people` 决定选方案时标出哪一个。 |
compare | Array<{ name, values: Array<boolean | string> }> | sample rows | 对比表的行,每个方案一个值:true、false 或一小段文字。 |
currency | string | by locale | 所有价格使用的 ISO 货币代码。 |
billing | 'monthly' | 'yearly' | 'yearly' | 默认显示的付费周期。 |
unit | string | [one, many] | (n) => string | plants (sample) | 选方案小工具数的是什么:如 "杯"、["seat", "seats"],或一个把数量写成文字的函数。方案的 `limit` 用的就是这个单位。 |
steps | number[] | 1 … 40 | 滑块停靠的数值,例如 [100, 500, 1000, 5000]。不传时滑块从 `finder.min` 到 `finder.max`。 |
finder | { title?, lead?, label?, min?, max?, step?, shared?: string | false, people? } | false | — | 选方案小工具的文字和范围,集中在一个对象里:`lead` 是数量前的文字,`label` 给读屏,`shared` 是开关文字(false 隐藏开关;打开时方案需要 `people` 个席位,默认 2)。传 false 不显示小工具,改为标记 `featured` 的方案。 |
count / shared | number / boolean | 8 / false | 选方案小工具的初始值(`plants` 是 `count` 的旧名)。 |
loading | boolean | false | 价格加载时显示方案的骨架。 |
error | boolean | string | false | 显示带重试按钮的错误提示;传字符串可替换说明。 |
onChoose | (planId, billing) => Promise<boolean | void> | — | 开通方案。返回 false 则保留按钮,否则显示已开通。 |
onBillingChange / onRetry | (billing) => void / () => void | — | 分别在切换付费周期、点击出错提示里的重试时调用。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素 section 上。 |
装进你的项目
把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。
LandingPricing.jsxlanding-pricing.csscopy.jskit.jsxkit.cssui/base-button/ui/rolling-number/ui/alert-banner/ui/success-check/ui/elastic-switch/ui/range-slider/ui/skeleton-shimmer/ui/sliding-tabs/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。