Properties
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
size: PropTypes.string,
className: PropTypes.string
};
InputGroupAddOn.propTypes = {
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
addonType: PropTypes.oneOf(['prepend', 'append']).isRequired,
className: PropTypes.string
};
InputGroupButton.propTypes = {
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
addonType: PropTypes.oneOf(['prepend', 'append']).isRequired,
children: PropTypes.node,
groupClassName: PropTypes.string, // only used in shorthand
groupAttributes: PropTypes.object, // only used in shorthand
className: PropTypes.string
};
import React from 'react';
import { InputGroup, InputGroupAddon, Input } from 'reactstrap';
const Example = (props) => {
return (
<div>
<InputGroup size="lg">
<InputGroupAddon addonType="prepend">@lg</InputGroupAddon>
</InputGroup>
<br />
<InputGroup>
<InputGroupAddon addonType="prepend">@normal</InputGroupAddon>
<Input />
</InputGroup>
<br />
<InputGroup size="sm">
<InputGroupAddon addonType="prepend">@sm</InputGroupAddon>
<Input />
</InputGroup>
</div>
);
};
export default Example;
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).
import React from 'react';
import { InputGroup, InputGroupAddon, Button, Input } from 'reactstrap';
const Example = (props) => {
return (
<InputGroup>
<InputGroupAddon addonType="prepend">
<Button>To the Left!</Button>
</InputGroupAddon>
<Input />
</InputGroup>
<br />
<InputGroup>
<Input />
<InputGroupAddon addonType="append">
<Button color="secondary">To the Right!</Button>
</InputGroupAddon>
</InputGroup>
<br />
<InputGroup>
<InputGroupAddon addonType="prepend">
<Button color="danger">To the Left!</Button>
</InputGroupAddon>
<Input placeholder="and..." />
<InputGroupAddon addonType="append">
<Button color="success">To the Right!</Button>
</InputGroupAddon>
</InputGroup>
</div>
);
};