Progress

Progress - 图1

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <div className="text-center">0%</div>
  7. <Progress />
  8. <div className="text-center">25%</div>
  9. <Progress value="25" />
  10. <div className="text-center">50%</div>
  11. <Progress value={50} />
  12. <div className="text-center">75%</div>
  13. <Progress value={75} />
  14. <div className="text-center">100%</div>
  15. <Progress value="100" />
  16. <div className="text-center">Multiple bars</div>
  17. <Progress multi>
  18. <Progress bar value="15" />
  19. <Progress bar color="success" value="30" />
  20. <Progress bar color="info" value="25" />
  21. <Progress bar color="warning" value="20" />
  22. <Progress bar color="danger" value="5" />
  23. </Progress>
  24. </div>
  25. );
  26. };
  27. export default Example;

Properties

  1. Progress.propTypes = {
  2. multi: PropTypes.bool,
  3. bar: PropTypes.bool, // used in combination with multi
  4. tag: PropTypes.string,
  5. value: PropTypes.oneOfType([
  6. PropTypes.string,
  7. PropTypes.number,
  8. ]),
  9. max: PropTypes.oneOf([
  10. PropTypes.string,
  11. PropTypes.number,
  12. ]),
  13. animated: PropTypes.bool,
  14. striped: PropTypes.bool,
  15. color: PropTypes.string,
  16. className: PropTypes.string,
  17. barClassName: PropTypes.string // used to add class to the inner progress-bar element
  18. };
  19. Progress.defaultProps = {
  20. tag: 'progress',
  21. value: 0,
  22. max: 100,
  23. };

Color Variants

Progress - 图2

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <Progress value={2 * 5} />
  7. <Progress color="success" value="25" />
  8. <Progress color="info" value={50} />
  9. <Progress color="warning" value={75} />
  10. <Progress color="danger" value="100" />
  11. </div>
  12. );
  13. };
  14. export default Example;

Labels

Progress - 图3

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <Progress value="25">25%</Progress>
  7. <Progress value={50}>1/2</Progress>
  8. <Progress value={75}>You're almost there!</Progress>
  9. <Progress color="success" value="100">You did it!</Progress>
  10. <Progress multi>
  11. <Progress bar value="15">Meh</Progress>
  12. <Progress bar color="success" value="30">Wow!</Progress>
  13. <Progress bar color="info" value="25">Cool</Progress>
  14. <Progress bar color="warning" value="20">20%</Progress>
  15. <Progress bar color="danger" value="5">!!</Progress>
  16. </Progress>
  17. </div>
  18. );
  19. };
  20. export default Example;

Striped

Progress - 图4

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <Progress striped value={2 * 5} />
  7. <Progress striped color="success" value="25" />
  8. <Progress striped color="info" value={50} />
  9. <Progress striped color="warning" value={75} />
  10. <Progress striped color="danger" value="100" />
  11. <Progress multi>
  12. <Progress striped bar value="10" />
  13. <Progress striped bar color="success" value="30" />
  14. <Progress striped bar color="warning" value="20" />
  15. <Progress striped bar color="danger" value="20" />
  16. </Progress>
  17. </div>
  18. );
  19. };
  20. export default Example;

Animated

The animated prop also adds the striped prop; there is no need to pass both.

Progress - 图5

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <Progress animated value={2 * 5} />
  7. <Progress animated color="success" value="25" />
  8. <Progress animated color="info" value={50} />
  9. <Progress animated color="warning" value={75} />
  10. <Progress animated color="danger" value="100" />
  11. <Progress multi>
  12. <Progress animated bar value="10" />
  13. <Progress animated bar color="success" value="30" />
  14. <Progress animated bar color="warning" value="20" />
  15. <Progress animated bar color="danger" value="20" />
  16. </Progress>
  17. </div>
  18. );
  19. };
  20. export default Example;

Multiple bars / Stacked

Progress - 图6

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <div className="text-center">Plain</div>
  7. <Progress multi>
  8. <Progress bar value="15" />
  9. <Progress bar color="success" value="20" />
  10. <Progress bar color="info" value="25" />
  11. <Progress bar color="warning" value="20" />
  12. <Progress bar color="danger" value="15" />
  13. </Progress>
  14. <div className="text-center">With Labels</div>
  15. <Progress multi>
  16. <Progress bar value="15">Meh</Progress>
  17. <Progress bar color="success" value="35">Wow!</Progress>
  18. <Progress bar color="warning" value="25">25%</Progress>
  19. <Progress bar color="danger" value="25">LOOK OUT!!</Progress>
  20. </Progress>
  21. <div className="text-center">Stripes and Animations</div>
  22. <Progress multi>
  23. <Progress bar striped value="15">Stripes</Progress>
  24. <Progress bar animated color="success" value="30">Animated Stripes</Progress>
  25. <Progress bar color="info" value="25">Plain</Progress>
  26. </Progress>
  27. </div>
  28. );
  29. };
  30. export default Example;

Max value

Progress - 图7

  1. import React from 'react';
  2. import { Progress } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <div className="text-center">1 of 5</div>
  7. <Progress value="1" max="5" />
  8. <div className="text-center">50 of 135</div>
  9. <Progress value={50} max="135" />
  10. <div className="text-center">75 of 111</div>
  11. <Progress value={75} max={111} />
  12. <div className="text-center">463 of 500</div>
  13. <Progress value="463" max={500} />
  14. <div className="text-center">Various (40) of 55</div>
  15. <Progress multi>
  16. <Progress bar value="5" max={55}>5</Progress>
  17. <Progress bar color="success" value="15" max={55}>15</Progress>
  18. <Progress bar color="warning" value="10" max={55}>10</Progress>
  19. <Progress bar color="danger" value="10" max={55}>10</Progress>
  20. </Progress>
  21. </div>
  22. );
  23. };
  24. export default Example;