Pricing card component
This lesson covers the creation of a more complex and fully responsive Pricing Card component using shadcn/ui styles.
Creating card component
- Add a text element.
- Apply the text-lg/semibold typography style and set text color to base/foreground.
- Add a Description below the title.
- Use text-sm/normal style and base/muted-foreground color.
- Paste your content using Paste and Match Style.
- Select both text elements and press Shift + A to create an auto-layout frame.
- Name this frame Flex Vertical and apply a spacing-1 gap.
- Duplicate this frame using Alt and move it to the bottom.
- Update the text and change the top text style to text-2xl/semibold.
- Update the price description below with text-sm/normal style and base/muted-foreground color.
- Group the top and price blocks into a new Flex Vertical frame.
- Start building a list using a check icon and text.
- Set icon size to w-5 and h-5.
- Apply base/muted-foreground color to the text.
- Wrap icon and text in a frame with spacing-2 gap and name it List Item.
- Duplicate List Item to create a full list.
- Wrap the list in a frame with spacing-4 gap.
- Select all icons and apply base/primary color.
- Combine the top content block and list in one frame with spacing-6 gap.
- Ensure left group has Fill set for height.
- Add an Outline Button from Assets.
- Wrap all elements in a final container frame.
- Set width to Fill and apply 24px padding and spacing.
- Set background to base/card, border to base/border, rounded-2xl radius.
- Update button text and name the component Pricing Card.
- Create a component from it and add a Mobile variant.
- In the Mobile version, change layout to vertical, height to Hug, width to 360px, and spacing to spacing-3.
- Group both variants under Breakpoint as Desktop and Mobile.
- Duplicate the component with Alt + Shift to create a new Type variant.
- Change background and border to base/primary, update text colors, reduce description opacity to 80%.
- Change the button to Secondary and name the new variant Primary.
- Open Propstar plugin and generate a property table.
- Your component is now complete and production-ready.
Creating pricing section
Now, when you have both card components created you can easily use them within Pro Blocks to create your unique sections. Follow the guide below to create a pricing section that will use the new cards.
- Install Pro Blocks styles:
npx shadcn@latest add https://pro-blocks-v4.vercel.app/r/pro-blocks-styles.json
- Install the Empty Landing Page section:
npx shadcn@latest add "https://shadcndesign-pro-blocks.vercel.app/components?name=empty-lp-section-2&key=YOUR_LICENSE_KEY"
- Duplicate the empty-lp-section-2.tsx file.
- Rename it to custom-pricing-section.tsx.
- Rename the function
EmptyLpSection2()
toCustomPricingSection()
. - Change the section title and paragraph to match our design in Figma.
- Import your new cards.
- Replace the placeholder div with a div containing your cards:
<div className="flex flex-col gap-4 lg:flex-row lg:gap-6">
<PricingCardDefault />
<PricingCardPrimary />
</div>
That's it! Our new pricing section is responsive and ready to use.
Up next
Website Project (Lesson 3)
In this practice lesson, we'll modify the components used in our website, focusing on those within our website blocks.