CARD_COMPONENT_FIX.mdā¢4.3 kB
# ā
Card Component Usage Fix
## š **Issue Found**
The MCP had outdated Card component properties that didn't match the actual implementation.
**Was documenting:**
- `elevation` (property)
- `padding` (property)
- `hoverable` (property)
**Actually has:**
- `variant` (default, elevated, outlined, filled)
- `rounded` (border radius)
- `shadow` (shadow intensity)
- `backgroundColor`, `borderColor`, `gradient`
- `hoverEffect`, `clickable`, `fullWidth`
- `adaptToTheme`
- **Config pattern support** ā
---
## š **Updated Card Component Properties**
### **Individual Properties:**
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| `variant` | CardVariant | `default` | Visual variant (default, elevated, outlined, filled) |
| `rounded` | CardRounded | `md` | Border radius (none, sm, md, lg, xl, full) |
| `shadow` | CardShadow | `sm` | Shadow intensity (none, sm, md, lg, xl) |
| `backgroundColor` | string | `` | Custom background color (hex or CSS) |
| `borderColor` | string | `` | Custom border color (hex or CSS) |
| `gradient` | string | `` | CSS gradient background |
| `hoverEffect` | boolean | `false` | Apply hover effects |
| `clickable` | boolean | `false` | Make card clickable |
| `fullWidth` | boolean | `false` | Take full width |
| `adaptToTheme` | boolean | `true` | Adapt colors to dark/light mode |
### **Config Interface:**
```typescript
interface CardConfig {
variant?: CardVariant;
rounded?: CardRounded;
shadow?: CardShadow;
backgroundColor?: string;
borderColor?: string;
gradient?: string;
hoverEffect?: boolean;
clickable?: boolean;
fullWidth?: boolean;
adaptToTheme?: boolean;
}
```
---
## šÆ **Correct Usage Patterns**
### ā
**Config Pattern (Recommended):**
```typescript
import { Card } from '@ntv-scaffolding/component-pantry';
@Component({
standalone: true,
imports: [Card],
template: `
<ntv-card [config]="cardConfig">
<h2>My Card</h2>
<p>Content here</p>
</ntv-card>
`
})
export class MyComponent {
cardConfig = {
variant: 'elevated',
shadow: 'md',
rounded: 'lg',
hoverEffect: true
};
}
```
### ā
**Individual Properties:**
```html
<ntv-card
variant="outlined"
rounded="md"
shadow="sm"
[clickable]="true"
(cardClick)="handleCardClick($event)">
Clickable card
</ntv-card>
```
### ā
**Advanced - With Theme Adaptation:**
```html
<ntv-card [config]="{
gradient: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
adaptToTheme: true,
hoverEffect: true
}">
Beautiful gradient card
</ntv-card>
```
---
## š **Events**
| Event | Type | Description |
|-------|------|-------------|
| `cardClick` | Event | Emitted when card is clicked (only when clickable=true) |
**Example:**
```html
<ntv-card
[clickable]="true"
(cardClick)="onCardClicked($event)">
Click me
</ntv-card>
```
---
## šØ **Variants**
```
default ā Standard card appearance
elevated ā Card with shadow, appears raised
outlined ā Card with border, no fill
filled ā Card with filled background
```
**Example:**
```html
<ntv-card variant="elevated">Elevated card</ntv-card>
<ntv-card variant="outlined">Outlined card</ntv-card>
<ntv-card variant="filled">Filled card</ntv-card>
```
---
## š **Dark Mode Support**
The Card component supports automatic theme adaptation:
```html
<ntv-card [config]="{
backgroundColor: '#FF6B6B',
adaptToTheme: true
}">
Colors auto-adjust for dark mode
</ntv-card>
```
When `adaptToTheme: true`:
- Light colors darken in dark mode
- Dark colors lighten in dark mode
- Maintains contrast and readability
---
## ⨠**Key Features**
ā
**Config Pattern Support** - Like Button and Input
ā
**Theme Adaptation** - Dark/light mode support
ā
**Clickable Cards** - With keyboard accessibility
ā
**Custom Colors** - Background, border, gradients
ā
**Flexible Styling** - Variants, shadows, rounded corners
---
## š **Migration Note**
If you were using the old (incorrect) Card properties:
### ā **Old (Incorrect):**
```html
<ntv-card [elevation]="2" padding="2rem">
```
### ā
**New (Correct):**
```html
<ntv-card [config]="{
shadow: 'md',
variant: 'elevated'
}">
```
---
**Version**: 1.0.4 (Card Fix)
**Status**: ā
Fully corrected
**Date**: November 3, 2025