Button Group

Button Group - 图1

  1. import React from 'react';
  2. import { Button, ButtonGroup } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <ButtonGroup>
  7. <Button>Left</Button>
  8. <Button>Middle</Button>
  9. <Button>Right</Button>
  10. </ButtonGroup>
  11. );
  12. }
  13. }

Properties

  1. ButtonGroup.propTypes = {
  2. ariaLabel: PropTypes.string,
  3. className: PropTypes.string,
  4. role: PropTypes.string,
  5. size: PropTypes.string,
  6. vertical: PropTypes.bool
  7. };

Button Toolbar

Button Group - 图2

  1. import React from 'react';
  2. import { Button, ButtonGroup, ButtonToolbar } from 'reactstrap';
  3. export default class Example extends React.Component {
  4. render() {
  5. return (
  6. <ButtonToolbar>
  7. <ButtonGroup>
  8. <Button>1</Button>
  9. <Button>2</Button>
  10. <Button>3</Button>
  11. <Button>4</Button>
  12. </ButtonGroup>
  13. <ButtonGroup>
  14. <Button>5</Button>
  15. <Button>6</Button>
  16. <Button>7</Button>
  17. </ButtonGroup>
  18. <ButtonGroup>
  19. <Button>8</Button>
  20. </ButtonGroup>
  21. </ButtonToolbar>
  22. );
  23. }
  24. }

Sizing

Button Group - 图3

  1. <ButtonGroup size="lg">
  2. <Button>Left</Button>
  3. <Button>Middle</Button>
  4. <Button>Right</Button>
  5. </ButtonGroup>
  6. <ButtonGroup>
  7. <Button>Left</Button>
  8. <Button>Middle</Button>
  9. <Button>Right</Button>
  10. </ButtonGroup>
  11. <ButtonGroup size="sm">
  12. <Button>Left</Button>
  13. <Button>Middle</Button>
  14. <Button>Right</Button>
  15. </ButtonGroup>

Nesting

Button Group - 图4

  1. <ButtonGroup>
  2. <Button>1</Button>
  3. <Button>2</Button>
  4. <ButtonDropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}>
  5. <DropdownToggle caret>
  6. Dropdown
  7. </DropdownToggle>
  8. <DropdownMenu>
  9. <DropdownItem>Dropdown Link</DropdownItem>
  10. <DropdownItem>Dropdown Link</DropdownItem>
  11. </DropdownMenu>
  12. </ButtonDropdown>
  13. </ButtonGroup>

Vertical variation

Button Group - 图5

  1. <ButtonGroup vertical>
  2. <Button>1</Button>
  3. <Button>2</Button>
  4. <ButtonDropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}>
  5. <DropdownToggle caret>
  6. Dropdown
  7. </DropdownToggle>
  8. <DropdownMenu>
  9. <DropdownItem>Dropdown Link</DropdownItem>
  10. <DropdownItem>Dropdown Link</DropdownItem>
  11. </DropdownMenu>
  12. </ButtonDropdown>
  13. </ButtonGroup>