tables.mdx 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. ---
  2. title: Tables
  3. summary: Tables are a useful interface element that allows to visualise data and arrange it in a clear way. Thanks to that, users can browse a lot of information at once and a good table design will help you take care of its clarity.
  4. bootstrapLink: content/tables/
  5. description: Visualize data clearly with tables.
  6. ---
  7. ## Basic Table
  8. The basic table design has light padding and the presented data is separated wih horizontal dividers. It helps provide users with all the necessary information, without overwhelming them with visuals.
  9. The `.table` class adds basic styling to a table:
  10. ```html example height="360px" scrollable
  11. <div class="table-responsive">
  12. <table class="table table-vcenter">
  13. <thead>
  14. <tr>
  15. <th>Name</th>
  16. <th>Title</th>
  17. <th>Email</th>
  18. <th>Role</th>
  19. <th class="w-1"></th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <tr>
  24. <td>Paweł Kuna</td>
  25. <td class="text-secondary">
  26. UI Designer, Training
  27. </td>
  28. <td class="text-secondary">
  29. <a href="#" class="text-reset">paweluna@howstuffworks.com</a>
  30. </td>
  31. <td class="text-secondary">
  32. User
  33. </td>
  34. <td>
  35. <a href="#">Edit</a>
  36. </td>
  37. </tr>
  38. <tr>
  39. <td>Jeffie Lewzey</td>
  40. <td class="text-secondary">
  41. Chemical Engineer, Support
  42. </td>
  43. <td class="text-secondary">
  44. <a href="#" class="text-reset">jlewzey1@seesaa.net</a>
  45. </td>
  46. <td class="text-secondary">
  47. Admin
  48. </td>
  49. <td>
  50. <a href="#">Edit</a>
  51. </td>
  52. </tr>
  53. <tr>
  54. <td>Mallory Hulme</td>
  55. <td class="text-secondary">
  56. Geologist IV, Support
  57. </td>
  58. <td class="text-secondary">
  59. <a href="#" class="text-reset">mhulme2@domainmarket.com</a>
  60. </td>
  61. <td class="text-secondary">
  62. User
  63. </td>
  64. <td>
  65. <a href="#">Edit</a>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td>Dunn Slane</td>
  70. <td class="text-secondary">
  71. Research Nurse, Sales
  72. </td>
  73. <td class="text-secondary">
  74. <a href="#" class="text-reset">dslane3@epa.gov</a>
  75. </td>
  76. <td class="text-secondary">
  77. Owner
  78. </td>
  79. <td>
  80. <a href="#">Edit</a>
  81. </td>
  82. </tr>
  83. <tr>
  84. <td>Emmy Levet</td>
  85. <td class="text-secondary">
  86. VP Product Management, Accounting
  87. </td>
  88. <td class="text-secondary">
  89. <a href="#" class="text-reset">elevet4@senate.gov</a>
  90. </td>
  91. <td class="text-secondary">
  92. Admin
  93. </td>
  94. <td>
  95. <a href="#">Edit</a>
  96. </td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. </div>
  101. ```
  102. ## Responsive tables
  103. Use the `.table-responsive` class across each breakpoint for horizontal scrolling tables. If you want to create responsive tables up to a specific breakpoint, use `.table-responsive{-sm|-md|-lg|-xl}`. From that breakpoint and up, the table will behave normally, rather than scroll horizontally.
  104. ```html example height="12rem"
  105. <table class="table table-responsive">
  106. <thead>
  107. <tr>
  108. <th>#</th>
  109. <th class="text-nowrap">Heading 1</th>
  110. <th class="text-nowrap">Heading 2</th>
  111. <th class="text-nowrap">Heading 3</th>
  112. <th class="text-nowrap">Heading 4</th>
  113. <th class="text-nowrap">Heading 5</th>
  114. <th class="text-nowrap">Heading 6</th>
  115. <th class="text-nowrap">Heading 7</th>
  116. <th class="text-nowrap">Heading 8</th>
  117. <th class="text-nowrap">Heading 9</th>
  118. <th class="text-nowrap">Heading 10</th>
  119. </tr>
  120. </thead>
  121. <tbody>
  122. <tr>
  123. <th>1</th>
  124. <td>Cell</td>
  125. <td>Cell</td>
  126. <td>Cell</td>
  127. <td>Cell</td>
  128. <td>Cell</td>
  129. <td>Cell</td>
  130. <td>Cell</td>
  131. <td>Cell</td>
  132. <td>Cell</td>
  133. <td>Cell</td>
  134. </tr>
  135. <tr>
  136. <th>2</th>
  137. <td>Cell</td>
  138. <td>Cell</td>
  139. <td>Cell</td>
  140. <td>Cell</td>
  141. <td>Cell</td>
  142. <td>Cell</td>
  143. <td>Cell</td>
  144. <td>Cell</td>
  145. <td>Cell</td>
  146. <td>Cell</td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. ```
  151. ## No wrap
  152. If you don't want the table cell content to wrap to another line, use the `table-nowrap` class.
  153. ```html example height="10rem"
  154. <div class="table-responsive">
  155. <table class="table table-vcenter table-nowrap">
  156. <thead>
  157. <tr>
  158. <th>Name</th>
  159. <th>Title</th>
  160. <th>Email</th>
  161. <th>Role</th>
  162. <th></th>
  163. <th class="w-1"></th>
  164. </tr>
  165. </thead>
  166. <tbody>
  167. <tr>
  168. <td>Paweł Kuna</td>
  169. <td class="text-secondary">UI Designer, Training</td>
  170. <td class="text-secondary">
  171. <a href="#" class="text-reset">paweluna@howstuffworks.com</a>
  172. </td>
  173. <td class="text-secondary">User</td>
  174. <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, commodi cupiditate debitis deserunt
  175. expedita hic incidunt iste modi molestiae nesciunt non nostrum perferendis perspiciatis placeat praesentium
  176. quaerat quo repellendus, voluptates.</td>
  177. <td>
  178. <a href="#">Edit</a>
  179. </td>
  180. </tr>
  181. </tbody>
  182. </table>
  183. </div>
  184. ```
  185. ```html
  186. <div class="table-responsive">
  187. <table class="table table-vcenter table-nowrap">
  188. <thead>
  189. <tr>
  190. <th>Name</th>
  191. <th>Title</th>
  192. <th>Email</th>
  193. <th>Role</th>
  194. <th></th>
  195. <th class="w-1"></th>
  196. </tr>
  197. </thead>
  198. <tbody>
  199. <tr>
  200. <td>Paweł Kuna</td>
  201. <td class="text-secondary">
  202. UI Designer, Training
  203. </td>
  204. <td class="text-secondary">
  205. <a href="#" class="text-reset">paweluna@howstuffworks.com</a>
  206. </td>
  207. <td class="text-secondary">
  208. User
  209. </td>
  210. <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, commodi cupiditate debitis deserunt
  211. expedita hic incidunt iste modi molestiae nesciunt non nostrum perferendis perspiciatis placeat praesentium
  212. quaerat quo repellendus, voluptates.
  213. </td>
  214. <td>
  215. <a href="#">Edit</a>
  216. </td>
  217. </tr>
  218. <tr>
  219. <td>Jeffie Lewzey</td>
  220. <td class="text-secondary">
  221. Chemical Engineer, Support
  222. </td>
  223. <td class="text-secondary">
  224. <a href="#" class="text-reset">jlewzey1@seesaa.net</a>
  225. </td>
  226. <td class="text-secondary">
  227. Admin
  228. </td>
  229. <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, commodi cupiditate debitis deserunt
  230. expedita hic incidunt iste modi molestiae nesciunt non nostrum perferendis perspiciatis placeat praesentium
  231. quaerat quo repellendus, voluptates.
  232. </td>
  233. <td>
  234. <a href="#">Edit</a>
  235. </td>
  236. </tr>
  237. <tr>
  238. <td>Mallory Hulme</td>
  239. <td class="text-secondary">
  240. Geologist IV, Support
  241. </td>
  242. <td class="text-secondary">
  243. <a href="#" class="text-reset">mhulme2@domainmarket.com</a>
  244. </td>
  245. <td class="text-secondary">
  246. User
  247. </td>
  248. <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, commodi cupiditate debitis deserunt
  249. expedita hic incidunt iste modi molestiae nesciunt non nostrum perferendis perspiciatis placeat praesentium
  250. quaerat quo repellendus, voluptates.
  251. </td>
  252. <td>
  253. <a href="#">Edit</a>
  254. </td>
  255. </tr>
  256. <tr>
  257. <td>Dunn Slane</td>
  258. <td class="text-secondary">
  259. Research Nurse, Sales
  260. </td>
  261. <td class="text-secondary">
  262. <a href="#" class="text-reset">dslane3@epa.gov</a>
  263. </td>
  264. <td class="text-secondary">
  265. Owner
  266. </td>
  267. <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, commodi cupiditate debitis deserunt
  268. expedita hic incidunt iste modi molestiae nesciunt non nostrum perferendis perspiciatis placeat praesentium
  269. quaerat quo repellendus, voluptates.
  270. </td>
  271. <td>
  272. <a href="#">Edit</a>
  273. </td>
  274. </tr>
  275. <tr>
  276. <td>Emmy Levet</td>
  277. <td class="text-secondary">
  278. VP Product Management, Accounting
  279. </td>
  280. <td class="text-secondary">
  281. <a href="#" class="text-reset">elevet4@senate.gov</a>
  282. </td>
  283. <td class="text-secondary">
  284. Admin
  285. </td>
  286. <td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, commodi cupiditate debitis deserunt
  287. expedita hic incidunt iste modi molestiae nesciunt non nostrum perferendis perspiciatis placeat praesentium
  288. quaerat quo repellendus, voluptates.
  289. </td>
  290. <td>
  291. <a href="#">Edit</a>
  292. </td>
  293. </tr>
  294. </tbody>
  295. </table>
  296. </div>
  297. ```
  298. ## Table Variants
  299. ```html example height="360px" scrollable
  300. <table class="table">
  301. <thead>
  302. <tr>
  303. <th scope="col">Class</th>
  304. <th scope="col">Heading</th>
  305. <th scope="col">Heading</th>
  306. </tr>
  307. </thead>
  308. <tbody>
  309. <tr>
  310. <th scope="row">Default</th>
  311. <td>Cell</td>
  312. <td>Cell</td>
  313. </tr>
  314. <tr class="table-primary">
  315. <th scope="row">Primary</th>
  316. <td>Cell</td>
  317. <td>Cell</td>
  318. </tr>
  319. <tr class="table-secondary">
  320. <th scope="row">Secondary</th>
  321. <td>Cell</td>
  322. <td>Cell</td>
  323. </tr>
  324. <tr class="table-success">
  325. <th scope="row">Success</th>
  326. <td>Cell</td>
  327. <td>Cell</td>
  328. </tr>
  329. <tr class="table-danger">
  330. <th scope="row">Danger</th>
  331. <td>Cell</td>
  332. <td>Cell</td>
  333. </tr>
  334. <tr class="table-warning">
  335. <th scope="row">Warning</th>
  336. <td>Cell</td>
  337. <td>Cell</td>
  338. </tr>
  339. <tr class="table-info">
  340. <th scope="row">Info</th>
  341. <td>Cell</td>
  342. <td>Cell</td>
  343. </tr>
  344. <tr class="table-light">
  345. <th scope="row">Light</th>
  346. <td>Cell</td>
  347. <td>Cell</td>
  348. </tr>
  349. <tr class="table-dark">
  350. <th scope="row">Dark</th>
  351. <td>Cell</td>
  352. <td>Cell</td>
  353. </tr>
  354. </tbody>
  355. </table>
  356. ```
  357. ## Table with sticky header
  358. ```html example scrollable
  359. <table class="table">
  360. <thead class="sticky-top">
  361. <tr>
  362. <th scope="col">Class</th>
  363. <th scope="col">Heading</th>
  364. <th scope="col">Heading</th>
  365. </tr>
  366. </thead>
  367. <tbody>
  368. <tr>
  369. <th scope="row">Default</th>
  370. <td>Cell</td>
  371. <td>Cell</td>
  372. </tr>
  373. <tr>
  374. <th scope="row">Primary</th>
  375. <td>Cell</td>
  376. <td>Cell</td>
  377. </tr>
  378. <tr>
  379. <th scope="row">Secondary</th>
  380. <td>Cell</td>
  381. <td>Cell</td>
  382. </tr>
  383. <tr>
  384. <th scope="row">Success</th>
  385. <td>Cell</td>
  386. <td>Cell</td>
  387. </tr>
  388. <tr>
  389. <th scope="row">Danger</th>
  390. <td>Cell</td>
  391. <td>Cell</td>
  392. </tr>
  393. <tr>
  394. <th scope="row">Warning</th>
  395. <td>Cell</td>
  396. <td>Cell</td>
  397. </tr>
  398. <tr>
  399. <th scope="row">Info</th>
  400. <td>Cell</td>
  401. <td>Cell</td>
  402. </tr>
  403. <tr>
  404. <th scope="row">Light</th>
  405. <td>Cell</td>
  406. <td>Cell</td>
  407. </tr>
  408. <tr class="table-dark">
  409. <th scope="row">Dark</th>
  410. <td>Cell</td>
  411. <td>Cell</td>
  412. </tr>
  413. </tbody>
  414. </table>
  415. ```