Card
Cards are versatile containers for grouping related content and actions. They create visual separation and hierarchy in layouts.
When to use
- To group related information together
- To create visual separation between content sections
- To display product listings or portfolio items
- To show user profiles or team member information
- To create dashboard widgets or stats displays
Key features
- Flexible structure - Header, content, and footer sections
- Visual hierarchy - Built-in spacing and typography
- Interactive states - Clickable cards with hover effects
- Image support - Display media at the top of cards
- Responsive - Works in grid layouts and adapts to screen sizes
- Accessible - Semantic HTML structure
Anatomy
A card consists of:
- Container - The outer wrapper with border and shadow
- Header - Optional top section for titles
- Content - Main body area for text and elements
- Footer - Optional bottom section for actions
- Image - Optional media display area
Basic Card
Card Title
This is a basic card with simple content. Cards are great for grouping related information together.
Card with Header and Footer
Featured Article
Technology
Cards can have separate header and footer sections for better content organization.
Clickable Card
Card with Image
Design System
Cards can include images or media content at the top.
Card Grid Layout
Performance
Optimized for speed and efficiency across all devices.
Accessibility
Built with WCAG guidelines and best practices in mind.
Responsive
Adapts beautifully to any screen size or device.
Nested Cards
Parent Card
Cards can contain other cards for complex layouts.
Nested Card
This is a card inside another card.
Profile Card Example
Patrick Mast
UI/UX Designer
Creating beautiful and functional user interfaces with pm7-ui components.
Installation
npm install @pm7/core
CSS Classes
Class | Description |
---|---|
.pm7-card |
Base card container |
Variants | |
.pm7-card--outlined |
Card with a more prominent border |
.pm7-card--ghost |
Card with no border or shadow |
.pm7-card--elevated |
Card with larger shadow, no border |
.pm7-card--hoverable |
Card with hover lift effect |
Padding Modifiers | |
.pm7-card--sm |
Small padding |
.pm7-card--md |
Medium padding (default) |
.pm7-card--lg |
Large padding |
.pm7-card--no-padding |
No padding |
Status Modifiers | |
.pm7-card--success |
Success state (green) |
.pm7-card--warning |
Warning state (orange) |
.pm7-card--error |
Error state (red) |
.pm7-card--info |
Info state (blue) |
Structure Classes | |
.pm7-card-header |
Card header section |
.pm7-card-title |
Card title |
.pm7-card-description |
Card description/subtitle |
.pm7-card-subtitle |
Alias for pm7-card-description |
.pm7-card-content |
Main card content area |
.pm7-card-body |
Alias for pm7-card-content |
.pm7-card-footer |
Card footer section |
.pm7-card-image |
Full-width card image |
.pm7-card-image--top |
Image with rounded top corners, suitable for full-bleed images within a card that has `pm7-card--no-padding` |
Footer Alignment | |
.pm7-card-footer--start |
Left align footer content |
.pm7-card-footer--center |
Center align footer content |
.pm7-card-footer--between |
Space between footer items |
Grid Classes | |
.pm7-card-grid |
Responsive grid container |
.pm7-card-grid--2 |
2 column responsive grid |
.pm7-card-grid--3 |
3 column responsive grid |
.pm7-card-grid--4 |
4 column responsive grid |
.pm7-card-grid--fixed-2 |
Fixed 2 column grid |
.pm7-card-grid--fixed-3 |
Fixed 3 column grid |
.pm7-card-grid--fixed-4 |
Fixed 4 column grid |
Data Attributes
Cards do not use any special data attributes. They are purely CSS-based components.
Basic Usage
<div class="pm7-card">
<div class="pm7-card-content">
<h3>Card Title</h3>
<p>Card content goes here.</p>
</div>
</div>
Card Variants
<!-- Outlined card (thicker border) -->
<div class="pm7-card pm7-card--outlined">
<div class="pm7-card-content">
<p>Outlined card with prominent border</p>
</div>
</div>
<!-- Ghost card -->
<div class="pm7-card pm7-card--ghost">
<div class="pm7-card-content">
<p>Ghost card with no border or shadow</p>
</div>
</div>
<!-- Elevated card -->
<div class="pm7-card pm7-card--elevated">
<div class="pm7-card-content">
<p>Elevated card with larger shadow, no border</p>
</div>
</div>
<!-- Hoverable card -->
<a href="#" class="pm7-card pm7-card--hoverable">
<div class="pm7-card-content">
<h3>Clickable Card</h3>
<p>This entire card is clickable with hover effect.</p>
</div>
</a>
Status Cards
<!-- Success card -->
<div class="pm7-card pm7-card--success">
<div class="pm7-card-header">
<h3 class="pm7-card-title">Success!</h3>
</div>
<div class="pm7-card-content">
<p>Operation completed successfully.</p>
</div>
</div>
<!-- Warning card -->
<div class="pm7-card pm7-card--warning">
<div class="pm7-card-header">
<h3 class="pm7-card-title">Warning</h3>
</div>
<div class="pm7-card-content">
<p>Please review before proceeding.</p>
</div>
</div>
Card Grid System
<!-- Responsive grid (auto-fill) -->
<div class="pm7-card-grid">
<div class="pm7-card">
<div class="pm7-card-content">Card 1</div>
</div>
<div class="pm7-card">
<div class="pm7-card-content">Card 2</div>
</div>
<div class="pm7-card">
<div class="pm7-card-content">Card 3</div>
</div>
</div>
<!-- Fixed 3 column grid -->
<div class="pm7-card-grid pm7-card-grid--fixed-3">
<div class="pm7-card">
<div class="pm7-card-content">Always 3 columns</div>
</div>
<!-- More cards... -->
</div>
CSS Customization
PM7 cards can be customized using CSS custom properties:
:root {
/* Border radius */
--pm7-card-radius: 0.5rem;
/* Padding variants */
--pm7-card-padding: 1.5rem;
--pm7-card-padding-sm: 1rem;
--pm7-card-padding-lg: 2rem;
/* Visual properties */
--pm7-card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
--pm7-card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1);
--pm7-card-border-width: 1px;
/* Footer */
--pm7-card-footer-bg: transparent;
}
JavaScript API
Cards don't require JavaScript initialization. For interactive features, use standard event handlers.
Grid System Details
The card grid system provides flexible layout options:
- Default grid: Auto-fills with minimum 300px columns
- Numbered grids (--2, --3, --4): Responsive with breakpoints
- Fixed grids (--fixed-2, etc.): Non-responsive, always maintain column count
- Gap: Uses
--pm7-spacing-6
(1.5rem) between cards
Best Practices
- Consistent sizing: Use grid layouts for equal-height cards
- Clear hierarchy: Use title, description, and content sections appropriately
- Interactive cards: Use
pm7-card--hoverable
for clickable cards - Status communication: Use status variants for important state information
- Padding choices: Select appropriate padding based on content density
- Images: Use
pm7-card--no-padding
withpm7-card-image--top
for edge-to-edge images
React Usage
The React Card component is currently in development. For now, use the CSS classes directly in your React projects:
function MyComponent() {
return (
<div className="pm7-card pm7-card--hoverable">
<div className="pm7-card-header">
<h3 className="pm7-card-title">Card Title</h3>
<p className="pm7-card-description">Card description</p>
</div>
<div className="pm7-card-content">
<p>Card content goes here.</p>
</div>
<div className="pm7-card-footer pm7-card-footer--between">
<button className="pm7-button pm7-button--outline">Cancel</button>
<button className="pm7-button pm7-button--primary">Save</button>
</div>
</div>
);
}
Accessibility
- Use semantic HTML elements within cards
- Maintain proper heading hierarchy
- For clickable cards, use a single link wrapper
- Ensure sufficient color contrast for all text
- Add
alt
text to images
Copy this link that can be used as documentation for working with this component:
🤖 AI-Optimized Documentation
This link contains complete Markdown documentation that is perfectly readable by AI assistants, developers, and other automated systems. Directly accessible on GitHub - including all essential PM7 Card implementation guidance.
Perfect for ChatGPT, Claude, and other AI code assistants