BaseCard
Foundation card component for consistent UI building blocks
Foundation card component with a header (title, description, icon, badge) and a built-in
loading skeleton. KPICard and DetailCard are built on it.
Header + loading state
BaseCard renders the header only when title, description, icon or headerBadge is set,
and swaps the whole card for a skeleton while isLoading is true.
Basic Usage
import { BaseCard } from '@telamonjs/ui'
import { User } from 'lucide-react'
export default function MyCard() {
return (
<BaseCard title='User Information' icon={User}>
<p>Card content here</p>
</BaseCard>
)
}Props
interface BaseCardProps {
// Header
title?: string // Card title
description?: string // Text under the title
icon?: LucideIcon | ReactNode | string // Component, rendered element, or Lucide icon name
iconClassName?: string // Classes for the icon (default: 'h-4 w-4')
headerBadge?: ReactNode // Rendered next to the icon, on the right of the header
// Content
children?: ReactNode // Card content
// Loading
isLoading?: boolean // Show the skeleton instead of the content (default: false)
loadingSkeletons?: {
title?: boolean // default: true
icon?: boolean // default: true
content?: boolean // default: true
description?: boolean // default: true
}
// Styling
className?: string // Classes on the card
headerClassName?: string // Classes on the header
contentClassName?: string // Classes on the content area
}There is no variant, padding, onClick, hoverable or actions prop — style the card with
className/contentClassName, put buttons in headerBadge, and wrap the card in a link or
button to make it clickable.
Examples
Basic Card
<BaseCard title='Simple Card'>
<p>This is a basic card with just a title and content.</p>
</BaseCard>With Icon
import { Settings } from 'lucide-react'
;<BaseCard title='Settings' icon={Settings}>
<p>Card content</p>
</BaseCard>icon also accepts a rendered element (icon={<Settings className='h-5 w-5' />}) or a Lucide
icon name (icon='Settings').
With Description
<BaseCard
title='User Statistics'
description='Overview of user activity for the last 30 days'
>
<div className='space-y-2'>
<p>Total Users: 1,234</p>
<p>Active Users: 892</p>
</div>
</BaseCard>With Header Badge
import { Badge } from '@telamonjs/ui'
<BaseCard
title="Notifications"
headerBadge={<Badge>5</Badge>}
>
<p>You have 5 unread notifications</p>
</BaseCard>With Header Actions
import { MoreVertical } from 'lucide-react'
import { Button } from '@telamonjs/ui'
;<BaseCard
title='User Profile'
headerBadge={
<Button variant='ghost' size='icon' aria-label='More actions'>
<MoreVertical className='w-4 h-4' />
</Button>
}
>
<p>Card content</p>
</BaseCard>Loading State
<BaseCard title='Revenue' icon={DollarSign} isLoading={isLoading}>
<div className='text-2xl font-bold'>{revenue}</div>
</BaseCard>
// Only skeleton the content lines
<BaseCard title='Revenue' isLoading loadingSkeletons={{ title: false, icon: false }}>
…
</BaseCard>Full-Width Content
<BaseCard title='Data Table' contentClassName='p-0'>
<DataTable columns={columns} data={data} />
</BaseCard>Useful for tables and charts that need full width.
Complete Example
'use client'
import {
BaseCard,
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@telamonjs/ui'
import { TrendingUp, TrendingDown, MoreVertical, type LucideIcon } from 'lucide-react'
interface StatsCardProps {
title: string
value: number
previousValue: number
icon: LucideIcon
isLoading?: boolean
}
export default function StatsOverviewCard({
title,
value,
previousValue,
icon,
isLoading,
}: StatsCardProps) {
const trend = ((value - previousValue) / previousValue) * 100
const isPositive = trend >= 0
return (
<BaseCard
title={title}
icon={icon}
isLoading={isLoading}
headerBadge={
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant='ghost' size='icon' aria-label='More actions'>
<MoreVertical className='w-4 h-4' />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align='end'>
<DropdownMenuItem>View Details</DropdownMenuItem>
<DropdownMenuItem>Export Data</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
}
>
<div className='space-y-2'>
<div className='text-3xl font-bold'>{value.toLocaleString()}</div>
<div
className={`flex items-center gap-1 ${isPositive ? 'text-green-600' : 'text-red-600'}`}
>
{isPositive ? (
<TrendingUp className='w-3 h-3' />
) : (
<TrendingDown className='w-3 h-3' />
)}
<span className='text-sm font-medium'>
{Math.abs(trend).toFixed(1)}%
</span>
</div>
<p className='text-sm text-muted-foreground'>
Previous: {previousValue.toLocaleString()}
</p>
</div>
</BaseCard>
)
}Use Cases
- Building custom cards - Foundation for domain-specific cards
- Consistent styling - Ensure all cards follow same design
- Rapid prototyping - Quickly build new card components
- Loading states - Get a matching skeleton without extra code
Components Built on BaseCard
DetailCard- Detail page information cardsKPICard- Key performance indicator cards- Custom domain cards in your application
Benefit: Consistent styling and behavior across all cards.
Layout Patterns
Grid of cards:
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6'>
<BaseCard title='Card 1'>{/* Content */}</BaseCard>
<BaseCard title='Card 2'>{/* Content */}</BaseCard>
<BaseCard title='Card 3'>{/* Content */}</BaseCard>
</div>Stack of cards:
<div className='space-y-6'>
<BaseCard title='Section 1'>{/* Content */}</BaseCard>
<BaseCard title='Section 2'>{/* Content */}</BaseCard>
</div>Best Practices
- Use for consistency - Build custom cards on top of BaseCard
- Semantic titles - Use clear, descriptive titles
- Icon usage - Add icons for visual hierarchy
- Actions sparingly - Limit header actions to 1-3
- Full-width content - Use
contentClassName='p-0'for tables and charts - Loading states - Pass
isLoadinginstead of rendering your own skeleton
Accessibility
- Built on the
Cardprimitives (CardHeader,CardTitle,CardDescription,CardContent) - The icon is decorative; the title carries the meaning
- Give icon-only buttons in
headerBadgeanaria-label
Styling Customization
Custom classes:
<BaseCard title='Custom Styled' className='border-blue-500 bg-blue-50'>
Content
</BaseCard>Tailwind modifiers:
<BaseCard title='Hover Effect' className='hover:shadow-xl transition-shadow'>
Content
</BaseCard>Related Components
- DetailCardHeader - Reusable card header
- DetailCard - Detail page cards
- KPICard - KPI card built on BaseCard
- StatCard - Statistics display
See Also
- Component Architecture - Design patterns
- Design System - UI consistency
Status: ✅ Stable