Cards
Bootstrap’s cards provide a flexible and extensible content container with multiple variants and options.
Basic Example
import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';function BasicExample() {return (<Card style={{ width: '18rem' }}><Card.Img variant="top" src="holder.js/100px180" /><Card.Body><Card.Title>Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text><Button variant="primary">Go somewhere</Button></Card.Body></Card>);}export default BasicExample;
Content types
Body
Use <Card.Body>
to pad content inside a <Card>
.
import Card from 'react-bootstrap/Card';function BodyOnlyExample() {return (<Card><Card.Body>This is some text within a card body.</Card.Body></Card>);}export default BodyOnlyExample;
Alternatively, you can use this shorthand version for Cards with body only, and no other children
import Card from 'react-bootstrap/Card';function BodyShorthandExample() {return <Card body>This is some text within a card body.</Card>;}export default BodyShorthandExample;
Title, text, and links
Using <Card.Title>
, <Card.Subtitle>
, and
<Card.Text>
inside the <Card.Body>
will line them up nicely.
<Card.Link>
s are used to line up links next to each other.
<Card.Text>
outputs <p>
tags around the content, so you can
use multiple <Card.Text>
s to create separate paragraphs.
import Card from 'react-bootstrap/Card';function TextExample() {return (<Card style={{ width: '18rem' }}><Card.Body><Card.Title>Card Title</Card.Title><Card.Subtitle className="mb-2 text-muted">Card Subtitle</Card.Subtitle><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text><Card.Link href="#">Card Link</Card.Link><Card.Link href="#">Another Link</Card.Link></Card.Body></Card>);}export default TextExample;
List Groups
Create lists of content in a card with a flush list group.
import Card from 'react-bootstrap/Card';import ListGroup from 'react-bootstrap/ListGroup';function ListGroupExample() {return (<Card style={{ width: '18rem' }}><ListGroup variant="flush"><ListGroup.Item>Cras justo odio</ListGroup.Item><ListGroup.Item>Dapibus ac facilisis in</ListGroup.Item><ListGroup.Item>Vestibulum at eros</ListGroup.Item></ListGroup></Card>);}export default ListGroupExample;
import Card from 'react-bootstrap/Card';import ListGroup from 'react-bootstrap/ListGroup';function ListGroupWithHeaderExample() {return (<Card style={{ width: '18rem' }}><Card.Header>Featured</Card.Header><ListGroup variant="flush"><ListGroup.Item>Cras justo odio</ListGroup.Item><ListGroup.Item>Dapibus ac facilisis in</ListGroup.Item><ListGroup.Item>Vestibulum at eros</ListGroup.Item></ListGroup></Card>);}export default ListGroupWithHeaderExample;
Kitchen Sink
import Card from 'react-bootstrap/Card';import ListGroup from 'react-bootstrap/ListGroup';function KitchenSinkExample() {return (<Card style={{ width: '18rem' }}><Card.Img variant="top" src="holder.js/100px180?text=Image cap" /><Card.Body><Card.Title>Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body><ListGroup className="list-group-flush"><ListGroup.Item>Cras justo odio</ListGroup.Item><ListGroup.Item>Dapibus ac facilisis in</ListGroup.Item><ListGroup.Item>Vestibulum at eros</ListGroup.Item></ListGroup><Card.Body><Card.Link href="#">Card Link</Card.Link><Card.Link href="#">Another Link</Card.Link></Card.Body></Card>);}export default KitchenSinkExample;
Header and Footer
You may add a header by adding a <Card.Header>
component.
import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';function WithHeaderExample() {return (<Card><Card.Header>Featured</Card.Header><Card.Body><Card.Title>Special title treatment</Card.Title><Card.Text>With supporting text below as a natural lead-in to additional content.</Card.Text><Button variant="primary">Go somewhere</Button></Card.Body></Card>);}export default WithHeaderExample;
A <CardHeader>
can be styled by passing a heading element
through the <as>
prop
import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';function WithHeaderStyledExample() {return (<Card><Card.Header as="h5">Featured</Card.Header><Card.Body><Card.Title>Special title treatment</Card.Title><Card.Text>With supporting text below as a natural lead-in to additional content.</Card.Text><Button variant="primary">Go somewhere</Button></Card.Body></Card>);}export default WithHeaderStyledExample;
import Card from 'react-bootstrap/Card';function WithHeaderAndQuoteExample() {return (<Card><Card.Header>Quote</Card.Header><Card.Body><blockquote className="blockquote mb-0"><p>{' '}Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integerposuere erat a ante.{' '}</p><footer className="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer></blockquote></Card.Body></Card>);}export default WithHeaderAndQuoteExample;
import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';function HeaderAndFooterExample() {return (<Card className="text-center"><Card.Header>Featured</Card.Header><Card.Body><Card.Title>Special title treatment</Card.Title><Card.Text>With supporting text below as a natural lead-in to additional content.</Card.Text><Button variant="primary">Go somewhere</Button></Card.Body><Card.Footer className="text-muted">2 days ago</Card.Footer></Card>);}export default HeaderAndFooterExample;
Images
Cards include a few options for working with images. Choose from appending “image caps” at either end of a card, overlaying images with card content, or simply embedding the image in a card.
Image caps
Similar to headers and footers, cards can include top and bottom “image caps”—images at the top or bottom of a card.
import Card from 'react-bootstrap/Card';function ImageAndTextExample() {return (<><Card><Card.Img variant="top" src="holder.js/100px180" /><Card.Body><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card><Card.Body><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body><Card.Img variant="bottom" src="holder.js/100px180" /></Card></>);}export default ImageAndTextExample;
Image Overlays
Turn an image into a card background and overlay your card’s text. Depending on the image, you may or may not need additional styles or utilities.
import Card from 'react-bootstrap/Card';function ImgOverlayExample() {return (<Card className="bg-dark text-white"><Card.Img src="holder.js/100px270" alt="Card image" /><Card.ImgOverlay><Card.Title>Card title</Card.Title><Card.Text>This is a wider card with supporting text below as a natural lead-into additional content. This content is a little bit longer.</Card.Text><Card.Text>Last updated 3 mins ago</Card.Text></Card.ImgOverlay></Card>);}export default ImgOverlayExample;
Navigation
Add some navigation to a card’s header (or block) with React Bootstrap’s Nav components.
import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';import Nav from 'react-bootstrap/Nav';function NavTabsExample() {return (<Card><Card.Header><Nav variant="tabs" defaultActiveKey="#first"><Nav.Item><Nav.Link href="#first">Active</Nav.Link></Nav.Item><Nav.Item><Nav.Link href="#link">Link</Nav.Link></Nav.Item><Nav.Item><Nav.Link href="#disabled" disabled>Disabled</Nav.Link></Nav.Item></Nav></Card.Header><Card.Body><Card.Title>Special title treatment</Card.Title><Card.Text>With supporting text below as a natural lead-in to additional content.</Card.Text><Button variant="primary">Go somewhere</Button></Card.Body></Card>);}export default NavTabsExample;
import Button from 'react-bootstrap/Button';import Card from 'react-bootstrap/Card';import Nav from 'react-bootstrap/Nav';function NavPillsExample() {return (<Card><Card.Header><Nav variant="pills" defaultActiveKey="#first"><Nav.Item><Nav.Link href="#first">Active</Nav.Link></Nav.Item><Nav.Item><Nav.Link href="#link">Link</Nav.Link></Nav.Item><Nav.Item><Nav.Link href="#disabled" disabled>Disabled</Nav.Link></Nav.Item></Nav></Card.Header><Card.Body><Card.Title>Special title treatment</Card.Title><Card.Text>With supporting text below as a natural lead-in to additional content.</Card.Text><Button variant="primary">Go somewhere</Button></Card.Body></Card>);}export default NavPillsExample;
Card Styles
Background Color
You can change a card's appearance by changing their <bg>
, and <text>
props.
import Card from 'react-bootstrap/Card';function BgColorExample() {return (<>{['Primary','Secondary','Success','Danger','Warning','Info','Light','Dark',].map((variant) => (<Cardbg={variant.toLowerCase()}key={variant}text={variant.toLowerCase() === 'light' ? 'dark' : 'white'}style={{ width: '18rem' }}className="mb-2"><Card.Header>Header</Card.Header><Card.Body><Card.Title>{variant} Card Title </Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card>))}</>);}export default BgColorExample;
Border Color
import Card from 'react-bootstrap/Card';function BorderExample() {return (<><Card border="primary" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Primary Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="secondary" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Secondary Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="success" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Success Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="danger" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Danger Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="warning" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Warning Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="info" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Info Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="dark" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Dark Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /><Card border="light" style={{ width: '18rem' }}><Card.Header>Header</Card.Header><Card.Body><Card.Title>Light Card Title</Card.Title><Card.Text>Some quick example text to build on the card title and make up thebulk of the card's content.</Card.Text></Card.Body></Card><br /></>);}export default BorderExample;
Card layout
Card Groups
import Card from 'react-bootstrap/Card';import CardGroup from 'react-bootstrap/CardGroup';function GroupExample() {return (<CardGroup><Card><Card.Img variant="top" src="holder.js/100px160" /><Card.Body><Card.Title>Card title</Card.Title><Card.Text>This is a wider card with supporting text below as a natural lead-into additional content. This content is a little bit longer.</Card.Text></Card.Body><Card.Footer><small className="text-muted">Last updated 3 mins ago</small></Card.Footer></Card><Card><Card.Img variant="top" src="holder.js/100px160" /><Card.Body><Card.Title>Card title</Card.Title><Card.Text>This card has supporting text below as a natural lead-in toadditional content.{' '}</Card.Text></Card.Body><Card.Footer><small className="text-muted">Last updated 3 mins ago</small></Card.Footer></Card><Card><Card.Img variant="top" src="holder.js/100px160" /><Card.Body><Card.Title>Card title</Card.Title><Card.Text>This is a wider card with supporting text below as a natural lead-into additional content. This card has even longer content than thefirst to show that equal height action.</Card.Text></Card.Body><Card.Footer><small className="text-muted">Last updated 3 mins ago</small></Card.Footer></Card></CardGroup>);}export default GroupExample;
Grid cards
Use Row
's grid column props to control how many cards to show per row.
import Card from 'react-bootstrap/Card';import Col from 'react-bootstrap/Col';import Row from 'react-bootstrap/Row';function GridExample() {return (<Row xs={1} md={2} className="g-4">{Array.from({ length: 4 }).map((_, idx) => (<Col key={idx}><Card><Card.Img variant="top" src="holder.js/100px160" /><Card.Body><Card.Title>Card title</Card.Title><Card.Text>This is a longer card with supporting text below as a naturallead-in to additional content. This content is a little bitlonger.</Card.Text></Card.Body></Card></Col>))}</Row>);}export default GridExample;