ServiceCard
A clickable card component designed to showcase services with an image, title, subtitle, description, and footer link. Features responsive design, hover effects, and dark mode support. Perfect for service listings, portfolios, or feature showcases.
✨ Features
- Responsive Image: Optimized Next.js Image component with aspect ratio
- Hover Effects: Smooth scale animations and border reveals
- Dark Mode Support: Automatic adaptation to light/dark themes
- Accessible: Semantic HTML with proper ARIA labels and focus states
- External Links: Optional new tab opening with secure rel attributes
- Default Content: Ready-to-use with sensible defaults
- Custom Colors: Warm beige/dark color scheme
📋 Prerequisites
This component requires:
- Next.js (with App Router)
- Tailwind CSS 4
🚀 Installation
# No additional dependencies required beyond Next.js and Tailwind
📁 Files Included
The component bundle includes:
index.tsx
- Main service card componentREADME.md
- This documentation
🎯 Basic Usage
1import ServiceCard from './components/service-card';23export default function ServicesPage() {4 return (5 <div className="grid md:grid-cols-3 gap-6">6 <ServiceCard />7 </div>8 );9}
The card renders with default "Web Design" content and placeholder image.
🔧 Props
Prop | Type | Default | Description |
---|---|---|---|
title | string | "Web Design" | Main heading of the service |
subtitle | string | "Creative & Responsive" | Small text above the title |
description | string | Default description | Short paragraph describing the service |
href | string | "#" | URL to navigate to when card is clicked |
footerLinkLabel | string | "Learn More" | Label text for the footer link |
imageSrc | string | Placeholder URL | Source URL of the image |
imageAlt | string | "Service Image" | Alt text for the image |
openInNewTab | boolean | false | Whether to open the link in a new tab |
All props are optional and have sensible defaults.
📖 Examples
Custom Service Cards
1<div className="grid md:grid-cols-3 gap-6">2 <ServiceCard3 title="Mobile Development"4 subtitle="iOS & Android"5 description="Native and cross-platform mobile apps that deliver exceptional user experiences."6 href="/services/mobile"7 footerLinkLabel="View Projects"8 imageSrc="/images/mobile-dev.jpg"9 imageAlt="Mobile development illustration"10 />1112 <ServiceCard13 title="UI/UX Design"14 subtitle="User-Centered"15 description="Beautiful and intuitive designs that put your users first and drive conversions."16 href="/services/design"17 footerLinkLabel="See Portfolio"18 imageSrc="/images/ui-design.jpg"19 imageAlt="UI/UX design mockups"20 />2122 <ServiceCard23 title="Consulting"24 subtitle="Strategic Planning"25 description="Expert guidance to help your business make the right technology decisions."26 href="/services/consulting"27 footerLinkLabel="Book Call"28 imageSrc="/images/consulting.jpg"29 imageAlt="Business consulting meeting"30 />31</div>
External Links
1<div className="grid md:grid-cols-2 gap-6">2 <ServiceCard3 title="GitHub Repository"4 subtitle="Open Source"5 description="Check out our latest open source projects and contribute to the community."6 href="https://github.com/yourorg"7 footerLinkLabel="Visit GitHub"8 openInNewTab={true}9 imageSrc="/images/github.jpg"10 imageAlt="GitHub profile"11 />1213 <ServiceCard14 title="Documentation"15 subtitle="Developer Resources"16 description="Comprehensive guides and API documentation for our services."17 href="https://docs.yourcompany.com"18 footerLinkLabel="Read Docs"19 openInNewTab={true}20 imageSrc="/images/documentation.jpg"21 imageAlt="Documentation pages"22 />23</div>
Without Images
1<ServiceCard2 title="Data Analytics"3 subtitle="Insights & Reporting"4 description="Transform your data into actionable insights with our analytics platform."5 href="/services/analytics"6 imageSrc="" // Empty string shows placeholder7 footerLinkLabel="Get Started"8/>
Service Grid Layout
1export default function ServicesSection() {2 const services = [3 {4 title: 'E-commerce',5 subtitle: 'Online Stores',6 description:7 'Custom online stores that convert visitors into customers.',8 href: '/services/ecommerce',9 imageSrc: '/images/ecommerce.jpg',10 },11 {12 title: 'SEO Optimization',13 subtitle: 'Search Rankings',14 description:15 'Improve your search engine visibility and organic traffic.',16 href: '/services/seo',17 imageSrc: '/images/seo.jpg',18 },19 {20 title: 'Content Strategy',21 subtitle: 'Brand Messaging',22 description:23 'Develop compelling content that resonates with your audience.',24 href: '/services/content',25 imageSrc: '/images/content.jpg',26 },27 ];2829 return (30 <section className="py-16">31 <div className="max-w-6xl mx-auto px-4">32 <h2 className="text-3xl font-bold text-center mb-12">33 Our Services34 </h2>35 <div className="grid md:grid-cols-3 gap-6">36 {services.map((service, index) => (37 <ServiceCard38 key={index}39 title={service.title}40 subtitle={service.subtitle}41 description={service.description}42 href={service.href}43 imageSrc={service.imageSrc}44 imageAlt={`${service.title} service`}45 />46 ))}47 </div>48 </div>49 </section>50 );51}
🎨 Visual Design
Color Scheme
- Light Mode:
bg-[#f0eae0]
(warm beige background) - Dark Mode:
bg-[#1a1a1a]
(dark charcoal background) - Gradient Overlay: Smooth transition from transparent to background color
Interactive States
- Hover: 105% image scale, border reveal, link color change
- Focus: Ring outline for keyboard navigation
- Transitions: 300ms smooth animations
Layout Structure
- Aspect Ratio: 5:4 for consistent image dimensions
- Padding: 6 (24px) internal spacing
- Border Radius: xl for modern rounded corners
🎭 Animation Details
Hover Effects
- Image Scale:
group-hover:scale-105
(5% zoom) - Border Reveal: Scale from 95% to 100% with opacity fade-in
- Link Color: Subtle color transition on footer link
- Duration: 300ms ease transitions
Image Handling
- Responsive: Uses Next.js Image with responsive sizing
- Fallback: Shows placeholder div when no image provided
- Optimization: Automatic image optimization and lazy loading
💡 Usage Tips
Grid Layouts
1// Responsive grid2<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">3 {/* Service cards */}4</div>56// Equal height cards7<div className="grid grid-cols-3 gap-6 auto-rows-fr">8 {/* Cards will have equal heights */}9</div>
Content Guidelines
- Titles: Keep to 1-3 words for best visual balance
- Subtitles: 2-4 words describing the category
- Descriptions: 1-2 sentences, around 60-120 characters
- Images: 1200x960px recommended (5:4 aspect ratio)
Accessibility Best Practices
1<ServiceCard2 title="Web Development"3 subtitle="Full-Stack"4 description="Complete web solutions from front-end to back-end."5 href="/services/web-dev"6 imageAlt="Web development code on multiple screens" // Descriptive alt text7 footerLinkLabel="View Web Services" // Clear action text8/>
📱 Responsive Behavior
Image Sizing
- Mobile: 90vw (90% viewport width)
- Desktop: 30vw (30% viewport width)
- Aspect Ratio: Maintained at 5:4 across all sizes
Layout Adaptation
- Cards: Stack vertically on mobile, grid on desktop
- Text: Responsive text sizing with consistent line heights
- Spacing: Proportional padding and margins
🌙 Dark Mode Support
Automatically adapts styling for dark mode:
Background Colors
- Card:
bg-[#f0eae0] dark:bg-[#1a1a1a]
- Gradient: Matches card background for seamless overlay
Text Colors
- Title:
text-neutral-900 dark:text-neutral-100
- Subtitle:
text-neutral-600 dark:text-neutral-400
- Description:
text-neutral-700 dark:text-neutral-300
- Link:
text-neutral-600 dark:text-neutral-300
Border & Effects
- Hover Border:
border-neutral-300 dark:border-neutral-700
- Focus Ring:
ring-neutral-400
(works in both modes)
♿ Accessibility Features
Semantic HTML
- Uses
<article>
for card content structure - Proper heading hierarchy with
<h3>
for titles <header>
for title/subtitle grouping
ARIA & Focus
aria-label
on link with title and subtitlearia-hidden="true"
on decorative arrow iconfocus-visible:ring-2
for keyboard navigation- External links get proper
rel="noopener noreferrer"
Screen Reader Support
- Descriptive alt text for images
- Clear link labels that make sense out of context
- Proper semantic structure for content hierarchy
🔧 Technical Notes
Image Optimization
- Uses Next.js Image component for automatic optimization
- Supports
unoptimized={false}
for external images - Lazy loading enabled by default
- Responsive sizing with
sizes
attribute
Performance
- CSS transforms use hardware acceleration
- Smooth transitions without layout shifts
- Optimized hover states with GPU-friendly properties