card-based-design – skill Thiết kế & UI cho agent AI
Hướng dẫn triển khai Card-Based Design cho Web và App. Kích hoạt khi người dùng muốn thẻ thông tin, bố cục kiểu Pinterest và các container nội dung ngắn gọn.
Cài skill card-based-design bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/card-based-design-78d2e.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /card-based-design – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/card-based-design-78d2e.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $card-based-design – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/card-based-design-78d2e.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /card-based-design – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/card-based-design-78d2e.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /card-based-design – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Card-Based Design
> "Bite-sized consumption. Encapsulating discrete pieces of information into distinct visual containers."
When to Use
Use this sub-style when the user's request matches the aesthetic described above. This is a child reference of the design-it skill and is not meant to be triggered directly.
Core Principles
1. Encapsulation: Every card is self-contained. It has an image, a title, a short description, and usually an action (like a button or a 'like' icon).
2. Responsive Flow: Cards easily reflow on different screen sizes (from a 4-column grid on desktop to a single column on mobile).
3. Clear Boundaries: Cards must visually pop off the background.
Visual DNA
- Colors: Very flexible. The background should be slightly darker or distinct from the card color. Sophisticated Neutral works well for a premium feel.
- Typography: Clear hierarchy within the card (Header, Subheader, Body).
- Styling: Standard
border-radius: 8pxand a medium drop shadow.
Web Implementation
- CSS Grid with
auto-fitor a Masonry layout. - CSS Example:
body {
background-color: #f0f2f5; /* Standard app background */
padding: 40px;
}
.card-grid {
display: grid;
/* Auto-responsive magic */
grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
gap: 24px;
}
.card {
background: #ffffff;
border-radius: 12px;
overflow: hidden; /* Keep images inside the rounded corners */
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
transition: transform 0.2s, box-shadow 0.2s;
display: flex;
flex-direction: column;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.card-image {
width: 100%;
height: 200px;
object-fit: cover;
border-bottom: 1px solid #eee;
}
.card-content {
padding: 20px;
flex-grow: 1; /* Pushes footer to the bottom */
}
.card-footer {
padding: 16px 20px;
border-top: 1px solid #eee;
display: flex;
justify-content: space-between;
}App Implementation
SwiftUI
struct ContentCard: View {
var body: some View {
VStack(alignment: .leading, spacing: 0) {
// Image Area
Rectangle()
.fill(Color.gray.opacity(0.2))
.frame(height: 160)
// Content Area
VStack(alignment: .leading, spacing: 8) {
Text("Card Title")
.font(.headline)
Text("A brief description of the content inside this discrete card container.")
.font(.subheadline)
.foregroundColor(.secondary)
.lineLimit(2)
}
.padding(16)
}
.background(Color.white)
.cornerRadius(12)
// Clean, subtle drop shadow
.shadow(color: Color.black.opacity(0.08), radius: 12, x: 0, y: 4)
}
}
// In your view:
// LazyVGrid(columns: [GridItem(.adaptive(minimum: 160), spacing: 16)]) { ... }VStackinside a background with.cornerRadiusand.shadowis the standard.- Use
LazyVGridwith.adaptive(minimum: 160)to automatically create a multi-column card grid that flows perfectly on iPad or iPhone.
Flutter
class ContentCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
elevation: 4, // Handles shadow natively
shadowColor: Colors.black.withOpacity(0.4),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
clipBehavior: Clip.antiAlias, // Critical: stops images from bleeding over corners
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// Image Area
Container(
height: 160,
color: Colors.grey[300],
width: double.infinity,
),
// Content Area
Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text('Card Title', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18)),
SizedBox(height: 8),
Text(
'A brief description of the content inside this discrete card container.',
style: TextStyle(color: Colors.black54),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
);
}
}
// In your view: Use GridView.builder for the layout- The native
Cardwidget does almost all the heavy lifting. - Critical fix: You must set
clipBehavior: Clip.antiAliason theCard, otherwise the top corners of your images will peek outside the border radius.
React Native
const ContentCard = () => {
return (
<View style={styles.card}>
<View style={styles.imageArea} />
<View style={styles.contentArea}>
<Text style={styles.title}>Card Title</Text>
<Text style={styles.description} numberOfLines={2}>
A brief description of the content inside this discrete card container.
</Text>
</View>
</View>
);
};
const styles = StyleSheet.create({
card: {
backgroundColor: '#FFF',
borderRadius: 12,
shadowColor: '#000',
shadowOffset: { width: 0, height: 4 },
shadowOpacity: 0.08,
shadowRadius: 12,
elevation: 4,
margin: 8,
// Keep the shadow wrapper unclipped; clip only a separate image/content wrapper.
},
imageArea: {
height: 160,
backgroundColor: '#E0E0E0',
},
contentArea: {
padding: 16,
},
title: {
fontSize: 18,
fontWeight: '600',
marginBottom: 8,
},
description: {
color: '#666',
}
});
// In your view: <FlatList numColumns={2} data={data} renderItem={...} />- Separate the outer shadow wrapper from an inner rounded clipping wrapper. Preserve visible focus and avoid nesting independent controls inside a whole-card button.
elevation: 4provides the drop shadow on Android, while theshadow*props handle iOS.- For a Pinterest/Masonry style (columns of different heights), you must use a third-party library like
react-native-masonry-list, asFlatListcannot do varying row heights in columns.
Jetpack Compose
@Composable
fun ContentCard() {
// ElevatedCard provides the shadow and shape natively
ElevatedCard(
elevation = CardDefaults.elevatedCardElevation(defaultElevation = 4.dp),
shape = RoundedCornerShape(12.dp),
colors = CardDefaults.elevatedCardColors(containerColor = Color.White),
modifier = Modifier.fillMaxWidth().padding(8.dp)
) {
Column {
// Image Area
Box(
modifier = Modifier
.fillMaxWidth()
.height(160.dp)
.background(Color.LightGray)
)
// Content Area
Column(modifier = Modifier.padding(16.dp)) {
Text(
text = "Card Title",
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold
)
Spacer(Modifier.height(8.dp))
Text(
text = "A brief description of the content inside this discrete card container.",
style = MaterialTheme.typography.bodyMedium,
color = Color.Gray,
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
}
}
}
}
// In your view: LazyVerticalGrid(columns = GridCells.Adaptive(minSize = 160.dp)) { ... }ElevatedCardis the perfect Material 3 component for this. It handles clipping and shadows automatically.- Use
GridCells.Adaptive(minSize = 160.dp)in aLazyVerticalGridto achieve an auto-flowing grid identical to CSS Gridauto-fit.
Do's and Don'ts
- DO: Make the entire card clickable, not just the title or image.
- DON'T: Put too much text in a card. If the user has to scroll *within* a card, the card is too big.
Limitations
- This is a styling reference and does not replace environment-specific validation, accessibility testing, or expert review.
- Ensure appropriate contrast ratios and responsive behaviors are verified separately.
Skill liên quan
- primer-design – Thiết kế và kiểm tra primer PCR và RT-qPCR bằng Primer3, với điều kiện nhiệt động học rõ…
- cc-skill-frontend-patterns – Mẫu phát triển frontend cho React, Next.js, quản lý state, tối ưu hiệu năng và thực hành…
- ckw-design – Điểm vào thiết kế frontend: hướng đi, hệ thống thiết kế, triết lý thị giác. Dùng bất cứ…
- inbox-triage – Chạy phân loại hộp thư đầy đủ bằng knowledge base được tạo bởi skill 'inbox-setup'…
- claymorphism – Hướng dẫn triển khai Claymorphism cho Web và App. Kích hoạt khi người dùng muốn các phần…
- interview-system-designer – Skill này nên được dùng khi người dùng yêu cầu "design interview processes", "create…
- popular-web-designs – 54 hệ thống thiết kế thực tế (Stripe, Linear, Vercel) dưới dạng HTML/CSS.
- codebase-design – Từ vựng chung để thiết kế module sâu. Dùng khi người dùng muốn thiết kế hoặc cải thiện…