1.0.0 • Published 4 years ago

@malcodeman/react-button-group v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-button-group

GitHub license npm code style: prettier

A button group is a set of two or more button segments. Within the control, all segments are equal in width. A button group is often used to switch between views of some data.

Getting started

yarn add @malcodeman/react-button-group
# or
npm install --save @malcodeman/react-button-group
import React from "react";
import { ButtonGroup } from "@malcodeman/react-button-group";

function App() {
  const [selected, setSelected] = React.useState([0]);

  return (
    <div>
      <ButtonGroup
        selected={selected}
        onClick={(event, index) => {
          setSelected([index]);
        }}
      >
        <StyledButton>One</StyledButton>
        <StyledButton>Two</StyledButton>
        <StyledButton>Three</StyledButton>
      </ButtonGroup>
    </div>
  );
}

export default App;

License

MIT