Tables


Tables - 图1

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Properties

  1. Table.propTypes = {
  2. // Pass in a Component to override default element
  3. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  4. size: PropTypes.string,
  5. bordered: PropTypes.bool,
  6. borderless: PropTypes.bool,
  7. striped: PropTypes.bool,
  8. dark: PropTypes.bool,
  9. hover: PropTypes.bool,
  10. responsive: PropTypes.bool,
  11. // Custom ref handler that will be assigned to the "ref" of the inner <table> element
  12. innerRef: PropTypes.oneOfType([
  13. PropTypes.func,
  14. PropTypes.string,
  15. PropTypes.object
  16. ])
  17. };

Dark table

Tables - 图2

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table dark>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Striped rows

Tables - 图3

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table striped>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Bordered table

Tables - 图4

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table bordered>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Borderless table

Tables - 图5

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table borderless>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Hoverable rows

Tables - 图6

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table hover>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Small table

Tables - 图7

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table size="sm">
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>First Name</th>
  11. <th>Last Name</th>
  12. <th>Username</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr>
  17. <th scope="row">1</th>
  18. <td>Mark</td>
  19. <td>Otto</td>
  20. <td>@mdo</td>
  21. </tr>
  22. <tr>
  23. <th scope="row">2</th>
  24. <td>Jacob</td>
  25. <td>Thornton</td>
  26. <td>@fat</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">3</th>
  30. <td>Larry</td>
  31. <td>the Bird</td>
  32. <td>@twitter</td>
  33. </tr>
  34. </tbody>
  35. </Table>
  36. );
  37. }
  38. }

Responsive table

Tables - 图8

  1. import React from 'react';
  2. import { Table } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <Table responsive>
  7. <thead>
  8. <tr>
  9. <th>#</th>
  10. <th>Table heading</th>
  11. <th>Table heading</th>
  12. <th>Table heading</th>
  13. <th>Table heading</th>
  14. <th>Table heading</th>
  15. <th>Table heading</th>
  16. </tr>
  17. </thead>
  18. <tbody>
  19. <tr>
  20. <th scope="row">1</th>
  21. <td>Table cell</td>
  22. <td>Table cell</td>
  23. <td>Table cell</td>
  24. <td>Table cell</td>
  25. <td>Table cell</td>
  26. <td>Table cell</td>
  27. </tr>
  28. <tr>
  29. <th scope="row">2</th>
  30. <td>Table cell</td>
  31. <td>Table cell</td>
  32. <td>Table cell</td>
  33. <td>Table cell</td>
  34. <td>Table cell</td>
  35. <td>Table cell</td>
  36. </tr>
  37. <tr>
  38. <th scope="row">3</th>
  39. <td>Table cell</td>
  40. <td>Table cell</td>
  41. <td>Table cell</td>
  42. <td>Table cell</td>
  43. <td>Table cell</td>
  44. <td>Table cell</td>
  45. </tr>
  46. </tbody>
  47. </Table>
  48. );
  49. }
  50. }