Skip to main content

Card

Cards contain content and actions about a single subject. Follows the Material Design 3 Card specification.

Usage

import { Card, Typography } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, justifyContent: 'center', padding: 16 }}>
<Card variant="elevated">
<Typography variant="titleMedium">Card Title</Typography>
<Typography variant="bodyMedium">Card content goes here.</Typography>
</Card>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Variants

VariantUse case
elevatedDefault surface with shadow
filledFilled surface, no shadow
outlinedBordered surface, no shadow

Interactive Card

When onPress is provided, the card renders as a Pressable with state-layer feedback:

import { Card, Typography } from '@onlynative/components'
import { ThemeProvider } from '@onlynative/core'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { Alert, View } from 'react-native'

export default function App() {
return (
<SafeAreaProvider>
<ThemeProvider>
<View style={{ flex: 1, justifyContent: 'center', padding: 16 }}>
<Card variant="filled" onPress={() => Alert.alert('Tapped')}>
<Typography>Tap me</Typography>
</Card>
</View>
</ThemeProvider>
</SafeAreaProvider>
)
}

Props

PropTypeDefaultRequiredDescription
childrenReactNode-YesContent rendered inside the card surface.
variantenumelevatedNoSurface style variant.
onPress() => void-NoWhen provided, the card becomes interactive (Pressable). Omit to render as a plain View.
disabledbooleanNoDisables the press interaction and reduces opacity. Only effective when `onPress` is provided.
containerColorstring-NoOverride the container (background) color. State-layer colors (hover, press) are derived automatically.