Properties

  1. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  2. size: PropTypes.string,
  3. className: PropTypes.string
  4. };
  5. InputGroupAddOn.propTypes = {
  6. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  7. addonType: PropTypes.oneOf(['prepend', 'append']).isRequired,
  8. className: PropTypes.string
  9. };
  10. InputGroupButton.propTypes = {
  11. tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  12. addonType: PropTypes.oneOf(['prepend', 'append']).isRequired,
  13. children: PropTypes.node,
  14. groupClassName: PropTypes.string, // only used in shorthand
  15. groupAttributes: PropTypes.object, // only used in shorthand
  16. className: PropTypes.string
  17. };

  1. import React from 'react';
  2. import { InputGroup, InputGroupAddon, Input } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <div>
  6. <InputGroup size="lg">
  7. <InputGroupAddon addonType="prepend">@lg</InputGroupAddon>
  8. </InputGroup>
  9. <br />
  10. <InputGroup>
  11. <InputGroupAddon addonType="prepend">@normal</InputGroupAddon>
  12. <Input />
  13. </InputGroup>
  14. <br />
  15. <InputGroup size="sm">
  16. <InputGroupAddon addonType="prepend">@sm</InputGroupAddon>
  17. <Input />
  18. </InputGroup>
  19. </div>
  20. );
  21. };
  22. export default Example;

Input Group - 图1

Button shorthand is a convenience method for adding just a button. It is triggered when only a single string is the child. A Button will be created and all of the props will be passed to it with the exception ofgroupClassName and groupAttributes, which are used to added classes and attributes to the wrapping container. This means you can add your onClick and other handlers directly toInputGroupButton. If you want your string to not be wrapped in a button, then you really want to use InputGroupAddon (see Addons above for that).

  1. import React from 'react';
  2. import { InputGroup, InputGroupAddon, Button, Input } from 'reactstrap';
  3. const Example = (props) => {
  4. return (
  5. <InputGroup>
  6. <InputGroupAddon addonType="prepend">
  7. <Button>To the Left!</Button>
  8. </InputGroupAddon>
  9. <Input />
  10. </InputGroup>
  11. <br />
  12. <InputGroup>
  13. <Input />
  14. <InputGroupAddon addonType="append">
  15. <Button color="secondary">To the Right!</Button>
  16. </InputGroupAddon>
  17. </InputGroup>
  18. <br />
  19. <InputGroup>
  20. <InputGroupAddon addonType="prepend">
  21. <Button color="danger">To the Left!</Button>
  22. </InputGroupAddon>
  23. <Input placeholder="and..." />
  24. <InputGroupAddon addonType="append">
  25. <Button color="success">To the Right!</Button>
  26. </InputGroupAddon>
  27. </InputGroup>
  28. </div>
  29. );
  30. };