区块 定价区块
定价 002如何使用此区块
1. 复制区块源代码并将其放入 src/components/pricing-002.jsx
文件中
区块(JavaScript)
import * as React from "react"export default function Block({ subheading, heading, text, items, ...props }) {return (<section py="4|6|12|20" {...props}><div variant="container"><div textAlign="center">{subheading && <p variant="subheading">{subheading}</p>}{heading && (<h2 variant="heading.h1" lineHeight="1">{heading}</h2>)}{text && (<p variant="text.lead" mt="4">{text}</p>)}</div>{items && (<divdisplay="grid"col="1|2|3"mt="4|6|8"gap="4|6|0"borderTopWidth="5"borderTopColor="primary">{items.map((item, index) => (<Pricing key={index} {...item} />))}</div>)}</div></section>)}export function Pricing({ heading, price, description, isSelected, ...props }) {return (<divbg={isSelected ? "muted" : "background"}textAlign="center"borderWidth="1px"px="4|4|8|10"py="8|8|12"{...props}><h3 variant="heading.h2" m="0">{heading}</h3><p variant="text.paragraph" mt="4" lineHeight="normal">{description}</p><div display="flex" mt="6|8" alignItems="center" justifyContent="center"><span fontSize="6xl" fontWeight="semibold">${price}</span><span fontSize="xs" ml="4">per user <br /> per month</span></div><buttonvariant={`button.${isSelected ? "primary" : "muted"}`}mt="6|8"w="100%">Select Plan</button></div>)}
2. 复制以下示例代码并将其添加到页面中。
用法(JavaScript)
import * as React from "react"import Block from "../src/components/pricing-002"export default function Example() {return (<Blocksubheading="Subheading"heading="Choose your plan"text="Start building for free, and upgrade anytime to unlock other features."items={[{heading: "Basic",description: "For small and medium-sized businesses",price: "49",},{heading: "Plus",isSelected: true,description:"For larger businesses with advanced administration tools",price: "299",},{heading: "Custom",description:"For very large businesses or those in highly regulated industries",price: "499",},]}/>)}