cards.mdx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. ---
  2. title: Cards
  3. description: Cards are flexible user interface elements, which help organize content into meaningful sections and make it easier to display on different screen sizes. Cards contain various smaller components, such as images, text, links and buttons and may act as an entry to more detailed information, helping users scan the page quickly and find the most relevant content.
  4. bootstrapLink: components/card/
  5. ---
  6. ## Table of contents
  7. ## Default card
  8. Use the `.card` and `.card-body` classes to create a card and use it as the basis for a more advanced card design. A card is a perfect way to organize content and make it look neat and tidy.
  9. ```html example code centered columns={1}
  10. <div class="card">
  11. <div class="card-body">
  12. <p>This is some text within a card body.</p>
  13. </div>
  14. </div>
  15. ```
  16. ## Card padding
  17. You can change the padding of a newly created card. To do it, use the `.card-sm`, `.card-md` or `.card-lg` classes.
  18. Cards with the `.card-sm` class are well suited for small items such as widgets, etc., while the `.card-lg` class can be used for large blocks of text. Padding will be automatically reduced on small devices, to fit the screen size.
  19. ```html example vertical centered separated height={500}
  20. <div class="card card-sm">
  21. <div class="card-body">
  22. This is some text within a card body.
  23. </div>
  24. </div>
  25. <div class="card">
  26. <div class="card-body">
  27. This is some text within a card body.
  28. </div>
  29. </div>
  30. <div class="card card-md">
  31. <div class="card-body">
  32. This is some text within a card body.
  33. </div>
  34. </div>
  35. <div class="card card-lg">
  36. <div class="card-body">
  37. This is some text within a card body.
  38. </div>
  39. </div>
  40. ```
  41. ```html
  42. <div class="card card-sm">...</div>
  43. <div class="card">...</div>
  44. <div class="card card-md">...</div>
  45. <div class="card card-lg">...</div>
  46. ```
  47. ## Card with title
  48. Add a title to your card by including the `.card-title` class within `.card-body`. You can also place the title inside the `.card-header` element to separate the title from the content with a horizontal line.
  49. ```html code example vertical centered separated height={400}
  50. <div class="card">
  51. <div class="card-body">
  52. <h3 class="card-title">Card title</h3>
  53. <p class="text-secondary">This is some text within a card body.</p>
  54. </div>
  55. </div>
  56. <div class="card">
  57. <div class="card-header">
  58. <h3 class="card-title">Card title</h3>
  59. </div>
  60. <div class="card-body">
  61. <p class="text-secondary">This is some text within a card body.</p>
  62. </div>
  63. </div>
  64. ```
  65. ## Card with title and image
  66. To create a more visually appealing card, add a title and an image. Thanks to that, the card will go well with your interface design and draw users' attention.
  67. ```html example centered columns={1} height={500} code
  68. <div class="card">
  69. <!-- Photo -->
  70. <div class="img-responsive img-responsive-21x9 card-img-top" style="background-image: url(/samples/photos/cup-of-coffee-and-an-open-book.jpg)"></div>
  71. <div class="card-body">
  72. <h3 class="card-title">Card with title and image</h3>
  73. <p class="text-secondary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam deleniti fugit incidunt, iste, itaque minima
  74. neque pariatur perferendis sed suscipit velit vitae voluptatem.</p>
  75. </div>
  76. </div>
  77. ```
  78. ## Blog post card
  79. Add an image to your blog post card to make it eye-catching. You can do it by adding the image in the `.card-img-top` class. Thanks to the `.d-flex` and `.flex-column` classes within `.card-body`, the author details will be displayed at the bottom of the card.
  80. ```html example centered columns={1} height={600} code
  81. <div class="card d-flex flex-column">
  82. <a href="#">
  83. <img class="card-img-top" src="/samples/photos/book-on-the-grass.jpg" alt="" />
  84. </a>
  85. <div class="card-body d-flex flex-column">
  86. <h3 class="card-title"><a href="#">How do you know she is a witch?</a></h3>
  87. <div class="text-secondary">Are you suggesting that coconuts migrate? No, no, no! Yes, yes. A bit. But she's got a wart. You ...</div>
  88. <div class="d-flex align-items-center pt-4 mt-auto">
  89. <span class="avatar" style="background-image: url(/samples/avatars/023m.jpg)"></span>
  90. <div class="ms-3">
  91. <a href="#" class="text-body">Maryjo Lebarree</a>
  92. <div class="text-secondary">3 days ago</div>
  93. </div>
  94. <div class="ms-auto">
  95. <a href="#" class="icon d-none d-md-inline-block ms-3 text-secondary">
  96. <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-heart" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  97. <path d="M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572"></path>
  98. </svg>
  99. </a>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. ```
  105. ## Row deck
  106. Add the `.row-deck` class to `.row`, if you want to display several cards next to one another. Thanks to that, they will all have the same height.
  107. ```html code example centered height="220px"
  108. <div class="row row-deck">
  109. <div class="col-md-4">
  110. <div class="card">
  111. <div class="card-body">Short content</div>
  112. </div>
  113. </div>
  114. <div class="col-md-4">
  115. <div class="card">
  116. <div class="card-body">Extra long content of card. Lorem ipsum dolor sit amet, consetetur sadipscing elitr</div>
  117. </div>
  118. </div>
  119. <div class="col-md-4">
  120. <div class="card">
  121. <div class="card-body">Short content</div>
  122. </div>
  123. </div>
  124. </div>
  125. ```
  126. ## Post card with aside image
  127. You can also add an image on the left side of the card. To do it, add the `.card-aside` class to the element with the `.card` class. Then add the image in the `.card-aside-column` element and it will be automatically centered and scaled to the right size.
  128. ```html example columns={2} centered height={400} code
  129. <div class="card d-flex flex-column">
  130. <div class="row row-0 flex-fill">
  131. <div class="col-md-3">
  132. <a href="#">
  133. <img src="/samples/photos/a-woman-works-on-a-laptop-at-home.jpg" class="w-100 h-100 object-cover" alt="Card side image" />
  134. </a>
  135. </div>
  136. <div class="col">
  137. <div class="card-body">
  138. <h3 class="card-title"><a href="#">Shut up!</a></h3>
  139. <div class="text-secondary">Burn her! How do you know she is a witch? You don't frighten us, English pig-dogs! Go and boil yo...</div>
  140. <div class="d-flex align-items-center pt-4 mt-auto">
  141. <span class="avatar" style="background-image: url(/samples/avatars/029m.jpg)"></span>
  142. <div class="ms-3">
  143. <a href="#" class="text-body">Egan Poetz</a>
  144. <div class="text-secondary">3 days ago</div>
  145. </div>
  146. <div class="ms-auto">
  147. <a href="#" class="icon d-none d-md-inline-block ms-3 text-red">
  148. <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-heart" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  149. <path d="M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572"></path>
  150. </svg>
  151. </a>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. ```
  159. ## Color variations
  160. Add a status color to your card, either at the top or on the side of the card, to customise it and make it more eye-catching.
  161. ```html example columns={2} centered height={400}
  162. <div class="row row-deck">
  163. <div class="col-md-6">
  164. <div class="card">
  165. <div class="card-status-top bg-danger"></div>
  166. <div class="card-body">
  167. <h3 class="card-title">Card with top status</h3>
  168. <p class="text-secondary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam deleniti fugit incidunt, iste, itaque minima
  169. neque pariatur perferendis sed suscipit velit vitae voluptatem.</p>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="col-md-6">
  174. <div class="card">
  175. <div class="card-status-start bg-green"></div>
  176. <div class="card-body">
  177. <h3 class="card-title">Card with side status</h3>
  178. <p class="text-secondary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam deleniti fugit incidunt, iste, itaque minima
  179. neque pariatur perferendis sed suscipit velit vitae voluptatem.</p>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. ```
  185. ```html
  186. <div class="card">
  187. <div class="card-status-top bg-danger"></div>
  188. <div class="card-body">
  189. <h3 class="card-title">Card with top status</h3>
  190. <p class="text-secondary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam deleniti fugit incidunt, iste, itaque minima
  191. neque pariatur perferendis sed suscipit velit vitae voluptatem.</p>
  192. </div>
  193. </div>
  194. <div class="card">
  195. <div class="card-status-start bg-green"></div>
  196. <div class="card-body">
  197. <h3 class="card-title">Card with side status</h3>
  198. <p class="text-secondary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam deleniti fugit incidunt, iste, itaque minima
  199. neque pariatur perferendis sed suscipit velit vitae voluptatem.</p>
  200. </div>
  201. </div>
  202. ```
  203. ## Stacked card
  204. Use the `card-stacked` class to stack up multiple cards, if you want to save screen space or create a visually appealing effect.
  205. ```html code example columns={1} centered height={300}
  206. <div class="card card-stacked">
  207. <div class="card-body">
  208. <h3 class="card-title">Stacked card</h3>
  209. <p class="text-secondary">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam deleniti fugit incidunt, iste, itaque minima
  210. neque pariatur perferendis sed suscipit velit vitae voluptatem.</p>
  211. </div>
  212. </div>
  213. ```
  214. ## Tabbed card
  215. Organize multiple cards into tabs to be able to display more content in a well-organized way and allow users to alternate between them easily.
  216. ```html example columns={2} centered height={400}
  217. <div class="card-tabs">
  218. <ul class="nav nav-tabs">
  219. <li class="nav-item"><a href="#tab-top-1" class="nav-link active" data-bs-toggle="tab">Tab 1</a></li>
  220. <li class="nav-item"><a href="#tab-top-2" class="nav-link" data-bs-toggle="tab">Tab 2</a></li>
  221. <li class="nav-item"><a href="#tab-top-3" class="nav-link" data-bs-toggle="tab">Tab 3</a></li>
  222. <li class="nav-item"><a href="#tab-top-4" class="nav-link" data-bs-toggle="tab">Tab 4</a></li>
  223. </ul>
  224. <div class="tab-content">
  225. <div id="tab-top-1" class="card tab-pane active show">
  226. <div class="card-body">
  227. <div class="card-title">Content of tab #1</div>
  228. <p class="text-secondary">
  229. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  230. </p>
  231. </div>
  232. </div>
  233. <div id="tab-top-2" class="card tab-pane">
  234. <div class="card-body">
  235. <div class="card-title">Content of tab #2</div>
  236. <p class="text-secondary">
  237. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  238. </p>
  239. </div>
  240. </div>
  241. <div id="tab-top-3" class="card tab-pane">
  242. <div class="card-body">
  243. <div class="card-title">Content of tab #3</div>
  244. <p class="text-secondary">
  245. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  246. </p>
  247. </div>
  248. </div>
  249. <div id="tab-top-4" class="card tab-pane">
  250. <div class="card-body">
  251. <div class="card-title">Content of tab #4</div>
  252. <p class="text-secondary">
  253. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  254. </p>
  255. </div>
  256. </div>
  257. </div>
  258. </div>
  259. ```
  260. ```html
  261. <!-- Cards with tabs component -->
  262. <div class="card-tabs">
  263. <!-- Cards navigation -->
  264. <ul class="nav nav-tabs">
  265. <li class="nav-item"><a href="#tab-top-1" class="nav-link active" data-bs-toggle="tab">Tab 1</a></li>
  266. <li class="nav-item"><a href="#tab-top-2" class="nav-link" data-bs-toggle="tab">Tab 2</a></li>
  267. <li class="nav-item"><a href="#tab-top-3" class="nav-link" data-bs-toggle="tab">Tab 3</a></li>
  268. <li class="nav-item"><a href="#tab-top-4" class="nav-link" data-bs-toggle="tab">Tab 4</a></li>
  269. </ul>
  270. <div class="tab-content">
  271. <!-- Content of card #1 -->
  272. <div id="tab-top-1" class="card tab-pane active show">
  273. <div class="card-body">
  274. <div class="card-title">Content of tab #1</div>
  275. <p class="text-secondary">
  276. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  277. </p>
  278. </div>
  279. </div>
  280. <!-- Content of card #2 -->
  281. <div id="tab-top-2" class="card tab-pane">
  282. <div class="card-body">
  283. <div class="card-title">Content of tab #2</div>
  284. <p class="text-secondary">
  285. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  286. </p>
  287. </div>
  288. </div>
  289. <!-- Content of card #3 -->
  290. <div id="tab-top-3" class="card tab-pane">
  291. <div class="card-body">
  292. <div class="card-title">Content of tab #3</div>
  293. <p class="text-secondary">
  294. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  295. </p>
  296. </div>
  297. </div>
  298. <!-- Content of card #4 -->
  299. <div id="tab-top-4" class="card tab-pane">
  300. <div class="card-body">
  301. <div class="card-title">Content of tab #4</div>
  302. <p class="text-secondary">
  303. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci, alias aliquid distinctio dolorem expedita, fugiat hic magni molestiae molestias odit.
  304. </p>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. ```