Card

v2.4

Card is a flexible component used to group and display content in a clear and concise format.

Source@chakra-ui/card

Import#

import { Card } from '@chakra-ui/react'

Usage#

Put in some content in the Card.Body to get a basic card.

<Card.Root>
<Card.Body>
<Text>View a summary of all your customers over the last month.</Text>
</Card.Body>
</Card.Root>

Rendering an image in a card#

Place the content within the Card.Body to get a nice padding around.

<Card.Root maxW='sm'>
<Card.Body>
<Image
src='https://images.unsplash.com/photo-1555041469-a586c61ea9bc?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80'
alt='Green double couch with wooden legs'
borderRadius='lg'
/>
<Stack mt='6' gap='3'>
<Heading size='md'>Living room Sofa</Heading>
<Text>
This sofa is perfect for modern tropical spaces, baroque inspired
spaces, earthy toned spaces and for people who love a chic design with a
sprinkle of vintage design.
</Text>
<Text color='blue.600' fontSize='2xl'>
$450
</Text>
</Stack>
</Card.Body>
<Card.Footer>
<Group gap='2'>
<Button colorPalette='blue'>Buy now</Button>
<Button variant='ghost' colorPalette='blue'>
Add to cart
</Button>
</Group>
</Card.Footer>
</Card.Root>

Horizontal Card#

The card component has display: flex by default. This means you make the content in a horizontal direction by passing direction="row".

<Card.Root
direction={{ base: 'column', sm: 'row' }}
overflow='hidden'
variant='outline'
>
<Image
objectFit='cover'
maxW={{ base: '100%', sm: '200px' }}
src='https://images.unsplash.com/photo-1667489022797-ab608913feeb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw5fHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=800&q=60'
alt='Caffe Latte'
/>
<Stack>
<Card.Body>
<Heading size='md'>The perfect latte</Heading>
<Text py='2'>
Caffè latte is a coffee beverage of Italian origin made with espresso
and steamed milk.
</Text>
</Card.Body>
<Card.Footer>
<Button colorPalette='blue'>Buy Latte</Button>
</Card.Footer>
</Stack>
</Card.Root>

Centering content in a card#

Card comes with an inherent display="flex" on it, so if you'd like to center the content of your card, you can do this easily by passing align="center" to the Card.

<Card.Root align='center'>
<Card.Header>
<Heading size='md'> Customer dashboard</Heading>
</Card.Header>
<Card.Body>
<Text>View a summary of all your customers over the last month.</Text>
</Card.Body>
<Card.Footer>
<Button colorPalette='blue'>View here</Button>
</Card.Footer>
</Card.Root>

Variants#

Pass the variant prop to change the visual look of the tabs. Set the value to either elevated, outline, subtle.

<Stack gap='4'>
{['elevated', 'outline', 'subtle'].map((variant) => (
<Card.Root key={variant} variant={variant}>
<Card.Header>
<Heading size='md'> {variant}</Heading>
</Card.Header>
<Card.Body>
<Text>variant = {variant}</Text>
</Card.Body>
</Card.Root>
))}
</Stack>

Sizes#

Chakra UI provides 3 Card sizes. Use the size prop to change the size and set the value to sm, md, or lg.

<Stack gap='4'>
{['sm', 'md', 'lg'].map((size) => (
<Card.Root key={size} size={size}>
<Card.Header>
<Heading size='md'> {size}</Heading>
</Card.Header>
<Card.Body>
<Text>size = {size}</Text>
</Card.Body>
</Card.Root>
))}
</Stack>
Edit this page on GitHub

Proudly made inNigeria by Segun Adebayo

Deployed by â–² Vercel