Card

A Card component serves as a visual container that groups related content and actions.
API Reference
Themed
Examples
Unstyled
This is an illustration of a Themed Card component with default configuration.
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>

API Reference

Import

To use this component in your project, include the following import statement in your file.
import { Card } from '@gluestack-ui/themed';

Anatomy

The structure provided below can help you identify and understand Card component's various parts.
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

Themed

The themed version of the component is a pre-styled version of the component, which allows you to quickly integrate the component into your project. The component's design and functionality are fully defined, allowing you to focus on the more important aspects of your project. To know more about Themed Library please visit this link.

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</ButtonText>
</Button>
<Button
px="$4"
py="$2"
variant="outline"
fontFamily="$heading"
borderColor="$borderLight300"
$dark-borderColor="$backgroundDark600"
sx={{
"@sm": {
flex: 1,
},
}}
>
<ButtonText
size="sm"
color="$textLight600"
$dark-color="$textDark400"
>
Wishlist
</ButtonText>
</Button>
</Box>
</Card>
)
}

Blog Card

This is an example of a Card component with a blog post.
function App() {
return (
<Card p="$5" borderRadius="$lg" maxWidth={360} m="$3">
<Text
fontSize="$sm"
fontStyle="normal"
fontFamily="$heading"
fontWeight="$normal"
lineHeight="$sm"
mb="$2"
sx={{
color: "$textLight700",
_dark: {
color: "$textDark200",
},
}}
>
May 15, 2023
</Text>
<VStack mb="$6">
<Heading size="md" fontFamily="$heading" mb="$4">
The Power of Positive Thinking
</Heading>
<Text size="sm" fontFamily="$heading">
Discover how the power of positive thinking can transform your life,
boost your confidence, and help you overcome challenges. Explore
practical tips and techniques to cultivate a positive mindset for
greater happiness and success.
</Text>
</VStack>
<Box flexDirection="row">
<Avatar mr="$3">
<AvatarFallbackText fontFamily="$heading">RR</AvatarFallbackText>
<AvatarImage
source={{
uri: "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dXNlcnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=800&q=60",
}}
/>
</Avatar>
<VStack>
<Heading size="sm" fontFamily="$heading" mb="$1">
John Smith
</Heading>
<Text size="sm" fontFamily="$heading">
Motivational Speaker
</Text>
</VStack>
</Box>
</Card>
)
}

Unstyled

All the components in gluestack-ui are unstyled by default. To customize your UI using the extendedTheme, please refer to this link. The import names of components serve as keys to customize each component.
Edit this page on GitHub