|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +title: Card |
| 4 | +description: Bootstrap’s cards provide a flexible and extensible content container with multiple variants and options. |
| 5 | +group: Components |
| 6 | +--- |
| 7 | + |
| 8 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 9 | +import { Button } from 'boot-cell/source/Form/Button'; |
| 10 | + |
| 11 | +import { Example } from '../../../source/component/Example'; |
| 12 | + |
| 13 | +## About |
| 14 | + |
| 15 | +A **card** is a flexible and extensible content container. It includes options for headers and footers, |
| 16 | +a wide variety of content, contextual background colors, and powerful display options. |
| 17 | +If you’re familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. |
| 18 | +Similar functionality to those components is available as modifier classes for cards. |
| 19 | + |
| 20 | +## Example |
| 21 | + |
| 22 | +Cards are built with as little markup and styles as possible, |
| 23 | +but still manage to deliver a ton of control and customization. |
| 24 | + |
| 25 | +Below is an example of a basic card with mixed content and a fixed width. |
| 26 | +Cards have no fixed width to start, so they’ll naturally fill the full width of its parent element. |
| 27 | +This is easily customized with our various [sizing options](#sizing). |
| 28 | + |
| 29 | +<Example> |
| 30 | + <Card |
| 31 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 32 | + title="Card title" |
| 33 | + text="Some quick example text to build on the card title and make up the bulk of the card's content." |
| 34 | + > |
| 35 | + <Button>Go somewhere</Button> |
| 36 | + </Card> |
| 37 | +</Example> |
| 38 | + |
| 39 | +```JavaScript |
| 40 | +import { render } from 'web-cell'; |
| 41 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 42 | +import { Button } from 'boot-cell/source/Form/Button'; |
| 43 | + |
| 44 | +render( |
| 45 | + <Card |
| 46 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 47 | + title="Card title" |
| 48 | + text="Some quick example text to build on the card title and make up the bulk of the card's content." |
| 49 | + > |
| 50 | + <Button>Go somewhere</Button> |
| 51 | + </Card> |
| 52 | +); |
| 53 | +``` |
| 54 | + |
| 55 | +## Content types |
| 56 | + |
| 57 | +Cards support a wide variety of content, including images, text, list groups, links, and more. |
| 58 | +Below are examples of what’s supported. |
| 59 | + |
| 60 | +### Body |
| 61 | + |
| 62 | +The building block of a card is the `.card-body`. Use it whenever you need a padded section within a card. |
| 63 | + |
| 64 | +<Example> |
| 65 | + <Card text="This is some text within a card body." /> |
| 66 | +</Example> |
| 67 | + |
| 68 | +```JavaScript |
| 69 | +import { render } from 'web-cell'; |
| 70 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 71 | + |
| 72 | +render( |
| 73 | + <Card text="This is some text within a card body." /> |
| 74 | +); |
| 75 | +``` |
| 76 | + |
| 77 | +### Titles, text, and links |
| 78 | + |
| 79 | +Card titles are used by adding `.card-title` to a `<h* />` tag. In the same way, |
| 80 | +links are added and placed next to each other by adding `.card-link` to an `<a />` tag. |
| 81 | + |
| 82 | +<Example> |
| 83 | + <Card |
| 84 | + title="Card title" |
| 85 | + subtitle="Card subtitle" |
| 86 | + text="Some quick example text to build on the card title and make up the bulk of the card's content." |
| 87 | + > |
| 88 | + <a className="card-link" href="javascript: void;"> |
| 89 | + Card link |
| 90 | + </a> |
| 91 | + <a className="card-link" href="javascript: void;"> |
| 92 | + Another link |
| 93 | + </a> |
| 94 | + </Card> |
| 95 | +</Example> |
| 96 | + |
| 97 | +```JavaScript |
| 98 | +import { render } from 'web-cell'; |
| 99 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 100 | + |
| 101 | +render( |
| 102 | + <Card |
| 103 | + title="Card title" |
| 104 | + subtitle="Card subtitle" |
| 105 | + text="Some quick example text to build on the card title and make up the bulk of the card's content." |
| 106 | + > |
| 107 | + <a className="card-link" href="javascript: void;"> |
| 108 | + Card link |
| 109 | + </a> |
| 110 | + <a className="card-link" href="javascript: void;"> |
| 111 | + Another link |
| 112 | + </a> |
| 113 | + </Card> |
| 114 | +); |
| 115 | +``` |
| 116 | + |
| 117 | +### Images |
| 118 | + |
| 119 | +`image` property places an image to the top of the card. With `text` property, text can be added to the card. |
| 120 | + |
| 121 | +<Example> |
| 122 | + <Card |
| 123 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 124 | + text="Some quick example text to build on the card title and make up the bulk of the card's content." |
| 125 | + /> |
| 126 | +</Example> |
| 127 | + |
| 128 | +```JavaScript |
| 129 | +import { render } from 'web-cell'; |
| 130 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 131 | + |
| 132 | +render( |
| 133 | + <Card |
| 134 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 135 | + text="Some quick example text to build on the card title and make up the bulk of the card's content." |
| 136 | + /> |
| 137 | +); |
| 138 | +``` |
| 139 | + |
| 140 | +### Header and footer |
| 141 | + |
| 142 | +Add an optional header and/or footer within a card. |
| 143 | + |
| 144 | +<Example> |
| 145 | + <Card |
| 146 | + header="Featured" |
| 147 | + title="Special title treatment" |
| 148 | + text="With supporting text below as a natural lead-in to additional content." |
| 149 | + > |
| 150 | + <Button>Go somewhere</Button> |
| 151 | + </Card> |
| 152 | +</Example> |
| 153 | + |
| 154 | +```JavaScript |
| 155 | +import { render } from 'web-cell'; |
| 156 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 157 | +import { Button } from 'boot-cell/source/Form/Button'; |
| 158 | + |
| 159 | +render( |
| 160 | + <Card |
| 161 | + header="Featured" |
| 162 | + title="Special title treatment" |
| 163 | + text="With supporting text below as a natural lead-in to additional content." |
| 164 | + > |
| 165 | + <Button>Go somewhere</Button> |
| 166 | + </Card> |
| 167 | +); |
| 168 | +``` |
| 169 | + |
| 170 | +<Example> |
| 171 | + <Card header="Quote"> |
| 172 | + <blockquote className="blockquote mb-0"> |
| 173 | + <p> |
| 174 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer |
| 175 | + posuere erat a ante. |
| 176 | + </p> |
| 177 | + <footer className="blockquote-footer"> |
| 178 | + Someone famous in <cite title="Source Title">Source Title</cite> |
| 179 | + </footer> |
| 180 | + </blockquote> |
| 181 | + </Card> |
| 182 | +</Example> |
| 183 | + |
| 184 | +```JavaScript |
| 185 | +import { render } from 'web-cell'; |
| 186 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 187 | + |
| 188 | +render( |
| 189 | + <Card header="Quote"> |
| 190 | + <blockquote className="blockquote mb-0"> |
| 191 | + <p> |
| 192 | + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer |
| 193 | + posuere erat a ante. |
| 194 | + </p> |
| 195 | + <footer className="blockquote-footer"> |
| 196 | + Someone famous in <cite title="Source Title">Source Title</cite> |
| 197 | + </footer> |
| 198 | + </blockquote> |
| 199 | + </Card> |
| 200 | +); |
| 201 | +``` |
| 202 | + |
| 203 | +<Example> |
| 204 | + <Card |
| 205 | + className="text-center" |
| 206 | + header="Featured" |
| 207 | + title="Special title treatment" |
| 208 | + text="With supporting text below as a natural lead-in to additional content." |
| 209 | + footer="2 days ago" |
| 210 | + > |
| 211 | + <Button>Go somewhere</Button> |
| 212 | + </Card> |
| 213 | +</Example> |
| 214 | + |
| 215 | +```JavaScript |
| 216 | +import { render } from 'web-cell'; |
| 217 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 218 | +import { Button } from 'boot-cell/source/Form/Button'; |
| 219 | + |
| 220 | +render( |
| 221 | + <Card |
| 222 | + className="text-center" |
| 223 | + header="Featured" |
| 224 | + title="Special title treatment" |
| 225 | + text="With supporting text below as a natural lead-in to additional content." |
| 226 | + footer="2 days ago" |
| 227 | + > |
| 228 | + <Button>Go somewhere</Button> |
| 229 | + </Card> |
| 230 | +); |
| 231 | +``` |
| 232 | + |
| 233 | +## Images |
| 234 | + |
| 235 | +### Image overlays |
| 236 | + |
| 237 | +Turn an image into a card background and overlay your card’s text. |
| 238 | +Depending on the image, you may or may not need additional styles or utilities. |
| 239 | + |
| 240 | +<Example> |
| 241 | + <Card |
| 242 | + className="bg-dark text-white" |
| 243 | + title="Card title" |
| 244 | + text="This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer." |
| 245 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 246 | + overlay |
| 247 | + > |
| 248 | + <time>Last updated 3 mins ago</time> |
| 249 | + </Card> |
| 250 | +</Example> |
| 251 | + |
| 252 | +```JavaScript |
| 253 | +import { render } from 'web-cell'; |
| 254 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 255 | + |
| 256 | +render( |
| 257 | + <Card |
| 258 | + className="bg-dark text-white" |
| 259 | + title="Card title" |
| 260 | + text="This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer." |
| 261 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 262 | + overlay |
| 263 | + > |
| 264 | + <time>Last updated 3 mins ago</time> |
| 265 | + </Card> |
| 266 | +); |
| 267 | +``` |
| 268 | + |
| 269 | +> Note that content should not be larger than the height of the image. |
| 270 | +> If content is larger than the image the content will be displayed outside the image. |
| 271 | +
|
| 272 | +## Horizontal |
| 273 | + |
| 274 | +Using a combination of grid and utility classes, cards can be made horizontal in a mobile-friendly and responsive way. |
| 275 | +Further adjustments may be needed depending on your card content. |
| 276 | + |
| 277 | +<Example> |
| 278 | + <Card |
| 279 | + title="Card title" |
| 280 | + text="This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer." |
| 281 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 282 | + direction="horizontal" |
| 283 | + > |
| 284 | + <small className="text-muted">Last updated 3 mins ago</small> |
| 285 | + </Card> |
| 286 | +</Example> |
| 287 | + |
| 288 | +```JavaScript |
| 289 | +import { render } from 'web-cell'; |
| 290 | +import { Card } from 'boot-cell/source/Content/Card'; |
| 291 | + |
| 292 | +render( |
| 293 | + <Card |
| 294 | + title="Card title" |
| 295 | + text="This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer." |
| 296 | + image="https://tech-query.me/medias/featureimages/6.jpg" |
| 297 | + direction="horizontal" |
| 298 | + > |
| 299 | + <small className="text-muted">Last updated 3 mins ago</small> |
| 300 | + </Card> |
| 301 | +); |
| 302 | +``` |
0 commit comments