Card

A Card component serves as a visual container that groups related content and actions.
Installation
API Reference
Examples
Examples
This is an illustration of a Card component.
size
variant
<Card size="md" variant="elevated" m="$3">
<Heading mb="$1" size="md">
Quick Start
</Heading>
<Text size="sm">Start building your next project in minutes</Text>
</Card>

Installation

Run the following command:

npx gluestack-ui add card

API Reference

To use this component in your project, include the following import statement in your file.
import { Card } from "@/components/ui/card"
export default () => <Card />

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Card

It inherits all the properties of React Native's View component.
Prop
Type
Default
size
sm | md | lg
md
variant
elevated | outline | ghost | filled
elevated

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Card with Image

This is an example of a Card component with an image.
function App() {
return (
<Card p="$5" borderRadius="$lg" maxWidth={360} m="$3">
<Image
mb="$6"
h={240}
width="$full"
borderRadius="$md"
source={{
uri: "https://images.unsplash.com/photo-1529693662653-9d480530a697?q=80&w=2831&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
}}
/>
<Text
fontSize="$sm"
fontStyle="normal"
fontFamily="$heading"
fontWeight="$normal"
lineHeight="$sm"
mb="$2"
sx={{
color: "$textLight700",
_dark: {
color: "$textDark200",
},
}}
>
May 15, 2023
</Text>
<Heading size="md" fontFamily="$heading" mb="$4">
The Power of Positive Thinking
</Heading>
<Link href="https://gluestack.io/" isExternal>
<HStack alignItems="center">
<LinkText
size="sm"
fontFamily="$heading"
fontWeight="$semibold"
color="$primary600"
$dark-color="$primary300"
textDecorationLine="none"
>
Read Blog
</LinkText>
<Icon
as={ArrowRightIcon}
size="sm"
color="$primary600"
mt="$0.5"
ml="$0.5"
$dark-color="$primary300"
/>
</HStack>
</Link>
</Card>
)
}

Advanced Composition

This is an example of a Card component with other components like Avatar, Image and Button.
function App() {
return (
<Card p="$6" borderRadius="$lg" maxWidth={360} m="$3">
<Box flexDirection="row">
<Avatar mr="$4">
<AvatarFallbackText fontFamily="$heading">JD</AvatarFallbackText>
<AvatarImage
source={{
uri: "https://images.unsplash.com/photo-1620403724159-40363e84a155?q=80&w=2646&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
}}
/>
</Avatar>
<VStack>
<Heading size="md" fontFamily="$heading" mb="$1">
Jane Doe
</Heading>
<Text size="sm" fontFamily="$heading">
janedoe@sample.com
</Text>
</VStack>
</Box>
<Box
my="$5"
sx={{
flexDirection: "column",
"@sm": {
my: "$6",
flexDirection: "row",
},
}}
>
<VStack
alignItems="center"
sx={{
pb: "$2",
"@sm": {
flex: 1,
pb: "$0",
borderRightWidth: 1,
borderColor: "$backgroundLight300",
_dark: {
borderRightColor: "$backgroundDark800",
},
},
}}
>
<Heading size="xs" fontFamily="$heading">
81
</Heading>
<Text size="xs">posts</Text>
</VStack>
<Divider
orientation="horizontal"
width="40%"
alignSelf="center"
sx={{
bg: "$backgroundLight300",
display: "flex",
_dark: {
bg: "$backgroundDark800",
},
"@sm": {
display: "none",
},
}}
/>
<VStack
alignItems="center"
sx={{
py: "$2",
"@sm": {
flex: 1,
py: "$0",
borderRightWidth: 1,
borderColor: "$backgroundLight300",
_dark: {
borderRightColor: "$backgroundDark800",
},
},
}}
>
<Heading size="xs" fontFamily="$heading">
5,281
</Heading>
<Text size="xs">followers</Text>
</VStack>
<Divider
orientation="horizontal"
width="40%"
alignSelf="center"
sx={{
bg: "$backgroundLight300",
display: "flex",
_dark: {
bg: "$backgroundDark800",
},
"@sm": {
display: "none",
},
}}
/>
<VStack
alignItems="center"
sx={{
pt: "$2",
"@sm": {
flex: 1,
pt: "$0",
},
}}
>
<Heading size="xs" fontFamily="$heading">
281
</Heading>
<Text size="xs">following</Text>
</VStack>
</Box>
<Box
mb="$5"
sx={{
flexDirection: "column",
"@sm": {
mb: "$6",
flexDirection: "row",
},
}}
>
<Image
mb="$3"
borderRadius="$md"
sx={{
width: "$full",
height: 140,
"@sm": {
mb: "$0",
mr: "$3",
width: 150,
height: 154,
},
}}
source={{
uri: "https://images.unsplash.com/photo-1592089416462-2b0cb7da8379?q=80&w=2865&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
}}
/>
<Image
borderRadius="$md"
sx={{
width: "$full",
height: 140,
"@sm": {
width: 150,
height: 154,
},
}}
source={{
uri: "https://images.unsplash.com/photo-1484406566174-9da000fda645?q=80&w=2425&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
}}
/>
</Box>
<Button py="$2" px="$4">
<ButtonText size="sm">Follow</ButtonText>
</Button>
</Card>
)
}

Product Card

This example illustrates a card showcasing a product.
function App() {
return (
<Card p="$5" borderRadius="$lg" maxWidth={360} m="$3">
<Image
mb="$6"
h={240}
width="$full"
borderRadius="$md"
source={{
uri: "https://images.unsplash.com/photo-1595231712325-9fedecef7575?w=800&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1yZWxhdGVkfDJ8fHxlbnwwfHx8fHw%3D",
}}
/>
<Text
fontSize="$sm"
fontStyle="normal"
fontFamily="$heading"
fontWeight="$normal"
lineHeight="$sm"
mb="$2"
sx={{
color: "$textLight700",
_dark: {
color: "$textDark200",
},
}}
>
Fashion Clothing
</Text>
<VStack mb="$6">
<Heading size="md" fontFamily="$heading" mb="$4">
Cotton Kurta
</Heading>
<Text size="sm" fontFamily="$heading">
Floral embroidered notch neck thread work cotton kurta in white and
black.
</Text>
</VStack>
<Box
flexDirection="column"
sx={{
"@sm": {
flexDirection: "row",
},
}}
>
<Button
px="$4"
py="$2"
fontFamily="$heading"
mr="$0"
mb="$3"
sx={{
"@sm": {
mr: "$3",
mb: "$0",
flex: 1,
},
}}
>
<ButtonText size="sm">Add to cart