
Anand Yadav
Software Engineer
The UserCard component provides a clean, consistent way to display user information with avatar, name, and description , perfect for user lists, team members, and profile displays
Installation
1npx shadcn@latest add "https://ace-ui-six.vercel.app/r/user-card.json"
Usage
1import { UserCard } from "@/components/ui/user-card";23export default function Example() {4return (5 <div>6 <UserCard7 avatarSrc="/avatars/john-doe.jpg"8 name="John Doe"9 description="Senior Frontend Developer"10 />11 </div>12);13}
Features
- Optimized Next.js Image component with proper sizing
- Circular avatar with overflow handling
- Responsive design that works on all screen sizes
- Full dark mode support with proper contrast
Props
| Prop | Type | Default | Description |
|---|---|---|---|
avatarSrc | string | — | Source URL for the user's avatar image |
name | string | — | User's display name |
description | string | — | User's role, title, or description |
className | string | — | Additional CSS classes for the card container |
Image Configuration
For Next.js projects, configure your next.config.js to handle external images:
1// next.config.js2/** @type {import('next').NextConfig} */3const nextConfig = {4images: {5 remotePatterns: [6 {7 protocol: 'https',8 hostname: 'images.unsplash.com',9 },10 {11 protocol: 'https',12 hostname: 'github.com',13 },14 {15 protocol: 'https',16 hostname: 'avatars.githubusercontent.com',17 },18 ],19},20}2122module.exports = nextConfig
Examples
1// Team page2<div className="max-w-4xl mx-auto p-6">3<h1 className="text-3xl font-bold mb-8">Our Team</h1>4<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">5 {teamMembers.map((member) => (6 <UserCard7 key={member.id}8 avatarSrc={member.avatar}9 name={member.name}10 description={member.role}11 className="hover:shadow-lg transition-shadow duration-300"12 />13 ))}14</div>15</div>1617// Comment section18<div className="space-y-4">19{comments.map((comment) => (20 <div key={comment.id} className="border-b pb-4">21 <UserCard22 avatarSrc={comment.author.avatar}23 name={comment.author.name}24 description={comment.createdAt}25 className="mb-3"26 />27 <p className="text-gray-700 dark:text-gray-300">{comment.content}</p>28 </div>29))}30</div>3132// Sidebar user info33<aside className="w-64 p-4">34<UserCard35 avatarSrc="/current-user-avatar.jpg"36 name="Current User"37 description="Online now"38 className="mb-6"39/>40</aside>