Overview
TheCallToAction component is a styled link button designed for primary actions and important calls-to-action. It features an eye-catching gradient background, rounded pill shape, and smooth hover effects. The component accepts any child content, making it flexible for text and icons.
Props
The URL or path that the button links to. Can be an internal route (e.g.,
/contact) or external URL (e.g., https://example.com) or mailto link (e.g., mailto:email@example.com).Usage
Basic CTA
CTA with Icon
External Link CTA
Multiple CTAs
Real-World Examples
Contact CTA Component (src/components/ContactCTA.astro):
src/pages/index.astro):
Styling Features
Visual Design
- Gradient Background: Uses
--gradient-accent-orangeCSS variable - Shape: Fully rounded pill shape with
border-radius: 999rem - Shadow: Medium box shadow (
--shadow-md) for depth - Spacing: Generous padding (0.56em 2em on mobile, 1.125rem 2.5rem on desktop)
Interactive States
- Hover Effect: Overlay with semi-transparent gray using mix-blend-mode
- Focus State: Same overlay effect for keyboard navigation
- Transition: Smooth color transition using
--theme-transition
Typography
- Responsive font sizing (large on mobile, extra-large on desktop)
- White space nowrap to prevent text wrapping
- Color optimized for contrast (
--accent-text-over) - Centered text alignment
Responsive Behavior
Mobile (< 20em)
- Base styling with medium padding
- Standard text size
Small Screens (≥ 20em)
- Font size:
var(--text-lg)
Desktop (≥ 50em)
- Increased padding: 1.125rem 2.5rem
- Larger font size:
var(--text-xl)
Accessibility
- Uses semantic
<a>element for proper link behavior - Keyboard accessible with visible focus states
- Screen reader friendly with clear link text
- Color contrast optimized with CSS custom properties
- Supports text-only child content for screen readers
Customization
With Custom Content
Multiple Lines
Best Practices
Design Tokens
The component relies on these CSS custom properties:--gradient-accent-orange: Primary gradient background--accent-text-over: Text color for contrast over gradient--shadow-md: Box shadow for depth--theme-transition: Timing function for smooth transitions--gray-999-basis: Base color for overlay effect--text-lg,--text-xl: Responsive font sizes