Directory
- Welcome
Pricing Section
The Pricing section component creates responsive, interactive pricing tables with built-in support for monthly/yearly billing toggles, feature comparisons, and customizable tiers.
Overview
The Pricing section helps you:
- Display pricing plans clearly and professionally
- Toggle between monthly and yearly billing options
- Highlight featured/popular plans
- Show feature comparisons across tiers
- Calculate and display savings for yearly plans
Basic Implementation
---import Pricing from '@/components/NST-components/sections/pricing/Pricing.astro';import { pricingData } from './your-pricing-data';---
<Pricing data={pricingData} />
Data Structure
The pricing component expects a structured data object with the following format:
interface PriceData { models: ['monthly' | 'yearly']; defaultModel: 'monthly' | 'yearly'; tiers: { id: string; name: string; description: string; featured?: boolean; price: { monthly: number; yearly: number; }; features: { [key: string]: { value: boolean | string | number; tooltip?: string; }; }; cta: { text: string; href: string; }; }[]; sections: { name: string; features: string[]; }[];}
Example Configuration
const pricingData = { models: ['monthly', 'yearly'], defaultModel: 'monthly', tiers: [ { id: 'free', name: 'Free', description: 'Perfect for getting started', price: { monthly: 0, yearly: 0, }, features: { Projects: { value: 1 }, 'Team Members': { value: 2 }, Support: { value: false }, }, cta: { text: 'Get Started', href: '/signup', }, }, // ... additional tiers ], sections: [ { name: 'Core Features', features: ['Projects', 'Team Members', 'Support'], }, // ... additional sections ],};
Features
Billing Toggle
- Seamless switching between monthly and yearly pricing
- Automatic yearly discount calculation
- Smooth price updates with transitions
- Accessible toggle controls
Tier Highlighting
{ // ... tier configuration featured: true, // Adds visual emphasis and "Most Popular" badge}
Feature Display Options
- Boolean features (checkmark/cross)
- Quantitative features (with units)
- Tooltip support for additional context
- Grouped feature sections
Styling Customization
The component supports various styling options through CSS classes and custom properties:
<Pricing data={pricingData} class="custom-pricing-section"/>
CSS Custom Properties
.custom-pricing-section { --pricing-featured-shadow: 0 4px 6px -1px rgb(var(--color-primary) / 0.1); --pricing-hover-transform: translateY(-4px); --pricing-transition-duration: 300ms;}
Accessibility Features
- ARIA labels for interactive elements
- Keyboard navigation support
- High contrast mode compatibility
- Screen reader optimized markup
- Focus management for toggles
Best Practices
-
Content Organization
- Group related features logically
- Order tiers from basic to premium
- Keep feature descriptions concise
- Use consistent terminology
-
Visual Hierarchy
- Highlight recommended plans appropriately
- Maintain clear price visibility
- Use adequate spacing between elements
- Ensure mobile responsiveness
-
Interaction Design
- Provide clear toggle feedback
- Animate price changes smoothly
- Include clear calls-to-action
- Maintain visible saving calculations
Common Customizations
Custom Feature Icons
<Pricing data={{ ...pricingData, features: { customIcon: { value: true, icon: 'path/to/icon.svg' } } }}/>
Custom CTA Styling
<Pricing data={{ ...pricingData, tiers: [{ ...tier, cta: { text: 'Get Started', href: '/signup', class: 'custom-cta-button' } }] }}/>
Related Components
- Button - Used for CTA elements
- Badge - For feature highlights
- Card - Base styling for pricing tiers
- Toggle - Monthly/yearly switch mechanism
Limited Time Launch Sale
Start building professional pricing sections today with our AstroJS starter template. Get instant access to the Pricing component and many more pre-built sections.
GET 60% OFF!