Card
A container component for grouping related content with header, body, and footer sections.
The Card component is a versatile container for grouping related content. It features a compound component API with header, title, description, content, and footer parts for flexible layouts. Built with NativeWind for consistent styling across platforms.
Preview
Installation
npx novaui-cli add cardImport
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from 'novaui-components'Basic Usage
The Card is a compound component with six parts:
Card- The outer containerCardHeader- Groups the title and descriptionCardTitle- The card headingCardDescription- Subtitle or description textCardContent- The main body areaCardFooter- Bottom section for actions
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from 'novaui-components'
import { Button } from 'novaui-components'
import { Text } from 'react-native'
export function BasicCard() {
return (
<Card>
<CardHeader>
<CardTitle>Card Title</CardTitle>
<CardDescription>Card description goes here.</CardDescription>
</CardHeader>
<CardContent>
<Text>This is the card content area where you can place any content.</Text>
</CardContent>
<CardFooter>
<Button label="Action" />
</CardFooter>
</Card>
)
}Header Only
A simple card with just a header:
<Card>
<CardHeader>
<CardTitle>Notifications</CardTitle>
<CardDescription>You have 3 unread messages.</CardDescription>
</CardHeader>
</Card>With Content
A card with header and content sections:
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from 'novaui-components'
import { View, Text } from 'react-native'
export function AccountCard() {
return (
<Card>
<CardHeader>
<CardTitle>Account</CardTitle>
<CardDescription>Manage your account settings and preferences.</CardDescription>
</CardHeader>
<CardContent>
<View className="gap-3">
<View className="flex-row items-center justify-between">
<Text>Email</Text>
<Text className="text-muted-foreground">john@example.com</Text>
</View>
<View className="flex-row items-center justify-between">
<Text>Plan</Text>
<Text className="text-muted-foreground">Pro</Text>
</View>
<View className="flex-row items-center justify-between">
<Text>Status</Text>
<Text className="text-muted-foreground">Active</Text>
</View>
</View>
</CardContent>
</Card>
)
}With Footer Actions
A card with action buttons in the footer:
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from 'novaui-components'
import { Button } from 'novaui-components'
import { View, Text, TextInput } from 'react-native'
export function CreateProjectCard() {
return (
<Card>
<CardHeader>
<CardTitle>Create Project</CardTitle>
<CardDescription>Deploy your new project in one click.</CardDescription>
</CardHeader>
<CardContent>
<View className="gap-2">
<Text className="text-sm font-medium">Name</Text>
<TextInput
placeholder="My Project"
className="h-10 w-full rounded-md border border-input bg-background px-3"
/>
</View>
</CardContent>
<CardFooter className="justify-between">
<Button variant="outline" label="Cancel" />
<Button label="Deploy" />
</CardFooter>
</Card>
)
}Custom Styling
Apply custom classes to any part of the Card:
<Card className="border-2 border-primary bg-primary/5">
<CardHeader>
<CardTitle className="text-primary">Featured</CardTitle>
<CardDescription className="text-primary/70">
A card with custom primary styling.
</CardDescription>
</CardHeader>
<CardContent>
<Text>Custom borders and background colors using className overrides.</Text>
</CardContent>
</Card>Card Grid
Display multiple cards in a grid layout:
import { Card, CardHeader, CardTitle, CardDescription } from 'novaui-components'
import { View } from 'react-native'
const stats = [
{ value: '128', label: 'Total Users' },
{ value: '$4,250', label: 'Revenue' },
{ value: '98%', label: 'Uptime' },
{ value: '42', label: 'Active Now' },
]
export function StatsGrid() {
return (
<View className="flex-row flex-wrap gap-4">
{stats.map((stat) => (
<Card key={stat.label} className="flex-1 min-w-[140px]">
<CardHeader>
<CardTitle>{stat.value}</CardTitle>
<CardDescription>{stat.label}</CardDescription>
</CardHeader>
</Card>
))}
</View>
)
}Props API
Card Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
CardHeader Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
CardTitle Props
Extends React.ComponentPropsWithoutRef<typeof Text>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
CardDescription Props
Extends React.ComponentPropsWithoutRef<typeof Text>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
CardContent Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
CardFooter Props
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
Best Practices
-
Consistent structure: Always use
CardHeaderfor title/description andCardContentfor body -
Footer for actions: Place buttons and links in
CardFooterfor consistent alignment -
Don't nest cards: Avoid placing cards inside cards — use sections instead
-
Responsive layouts: Use flex or grid wrappers to create responsive card grids
-
Shadow usage: The default shadow is subtle — increase it with
classNamefor elevated cards
Related Components
- Combine with
Buttonfor card actions - Use
Avatarinside cards for user profiles - Use
Badgefor status indicators on cards