Card (카드)
Card는 구조화된 콘텐츠를 위한 유연한 레이아웃 섹션을 제공하는 카드 컨테이너 컴포넌트예요. 헤더, 본문, 타이틀, 설명, 푸터 등의 섹션으로 콘텐츠를 체계적으로 구성할 수 있어요. Surface 컴포넌트를 확장하며 다양한 variant를 지원해요.
출처: 문서
본문
Import
import { Card } from 'heroui-native';
Anatomy
<Card>
<Card.Header>...</Card.Header>
<Card.Body>
<Card.Title>...</Card.Title>
<Card.Description>...</Card.Description>
</Card.Body>
<Card.Footer>...</Card.Footer>
</Card>
- Card: Surface 컴포넌트를 확장하는 메인 컨테이너예요. 설정 가능한 surface variant로 기본 카드 구조를 제공하고 전체 레이아웃을 처리해요.
- Card.Header: 아이콘이나 배지 같은 상단 정렬 콘텐츠용 헤더 섹션이에요.
- Card.Body:
flex-1을 가지는 메인 콘텐츠 영역으로,Card.Header와Card.Footer사이의 사용 가능한 공간을 모두 채워요. - Card.Title: 전경(foreground) 색상과 중간 글꼴 두께를 가진 타이틀 텍스트예요.
- Card.Description: muted 색상과 더 작은 글꼴 크기를 가진 설명 텍스트예요.
- Card.Footer: 버튼 같은 하단 정렬 액션용 푸터 섹션이에요.
Usage
Basic Usage
Card 컴포넌트는 정리된 콘텐츠를 위한 내장 섹션이 있는 컨테이너를 만들어요.
<Card>
<Card.Body>...</Card.Body>
</Card>
With Title and Description
타이틀과 설명 컴포넌트를 결합해 구조화된 텍스트 콘텐츠를 구성해요.
<Card>
<Card.Body>
<Card.Title>...</Card.Title>
<Card.Description>...</Card.Description>
</Card.Body>
</Card>
With Header and Footer
아이콘, 배지 또는 액션용 헤더와 푸터 섹션을 추가해요.
<Card>
<Card.Header>...</Card.Header>
<Card.Body>...</Card.Body>
<Card.Footer>...</Card.Footer>
</Card>
Variants
다양한 variant로 카드의 배경 모양을 제어해요.
<Card variant="default">...</Card>
<Card variant="secondary">...</Card>
<Card variant="tertiary">...</Card>
<Card variant="transparent">...</Card>
Horizontal Layout
flex-row 스타일을 사용해 가로형 카드를 만들어요.
<Card className="flex-row gap-4">
<Image source={...} className="size-24 rounded-lg" />
</Card>
Background Image
이미지를 절대 위치(absolute) 배경으로 사용해요.
<Card>
<Image source={...} className="absolute inset-0" />
<View className="gap-4">...</View>
</Card>
Example
import { Button, Card } from 'heroui-native';
import { Ionicons } from '@expo/vector-icons';
import { View } from 'react-native';
export default function CardExample() {
return (
<Card>
<View className="gap-4">
<Card.Body className="mb-4">
<View className="gap-1 mb-2">
<Card.Title className="text-pink-500">$450</Card.Title>
<Card.Title>Living room Sofa • Collection 2025</Card.Title>
</View>
<Card.Description>
This sofa is perfect for modern tropical spaces, baroque inspired
spaces.
</Card.Description>
</Card.Body>
<Card.Footer className="gap-3">
<Button variant="primary">Buy now</Button>
<Button variant="ghost">
<Button.Label>Add to cart</Button.Label>
<Ionicons name="bag-outline" size={16} />
</Button>
</Card.Footer>
</View>
</Card>
);
}
더 많은 예시는 GitHub repository에서 찾을 수 있어요.
API Reference
Card
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 카드 안에 렌더링할 콘텐츠 |
variant |
'default' | 'secondary' | 'tertiary' | 'transparent' |
'default' |
카드 표면의 시각적 variant |
className |
string |
- | 적용할 추가 CSS 클래스 |
animation |
"disable-all" | undefined |
undefined |
애니메이션 설정. "disable-all"을 사용하면 자식을 포함한 모든 애니메이션이 비활성화돼요 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props가 지원돼요 |
Card.Header
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 헤더 안에 렌더링할 자식 요소들 |
className |
string |
- | 추가 CSS 클래스 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props가 지원돼요 |
Card.Body
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 본문 안에 렌더링할 자식 요소들 |
className |
string |
- | 추가 CSS 클래스 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props가 지원돼요 |
Card.Footer
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 푸터 안에 렌더링할 자식 요소들 |
className |
string |
- | 추가 CSS 클래스 |
...ViewProps |
ViewProps |
- | 모든 표준 React Native View props가 지원돼요 |
Card.Title
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 타이틀 텍스트로 렌더링할 자식 요소들 |
className |
string |
- | 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text props가 지원돼요 |
Card.Description
| prop | type | default | 설명 |
|---|---|---|---|
children |
React.ReactNode |
- | 설명 텍스트로 렌더링할 자식 요소들 |
className |
string |
- | 추가 CSS 클래스 |
...TextProps |
TextProps |
- | 모든 표준 React Native Text props가 지원돼요 |