Reactstrap: How do I capture button group change event and values as checkboxes?

Created on 9 Feb 2018  路  3Comments  路  Source: reactstrap/reactstrap

I want to use button group as a checkbox. How can I do it? Could you please add some documentation on that. What methods do I use?

This should be radio buttons:

<ButtonGroup>
    <Button>AAA</Button>
    <Button>BBB</Button>
    <Button>CCC</Button>
</ButtonGroup>
question

Most helpful comment

See #300, Here is a demo: https://stackblitz.com/edit/reactstrap-v5beta-zxdfeh?file=Example.js
Since the state is managed by your component, you don't need use actual inputs (such as bootstrap does). You can just store the selected values in state and conditionally apply the active prop on each of the buttons which have values in your selected state.

All 3 comments

See #300, Here is a demo: https://stackblitz.com/edit/reactstrap-v5beta-zxdfeh?file=Example.js
Since the state is managed by your component, you don't need use actual inputs (such as bootstrap does). You can just store the selected values in state and conditionally apply the active prop on each of the buttons which have values in your selected state.

Switched over to plain old Bootstrap 4 and happy

Yep, works exactly the same. You manage the state yourself. The only thing reactstrap does for these components is abstract the classNames, so you adding the classNames yourself is the same thing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sjorsvanheuveln picture sjorsvanheuveln  路  3Comments

emlmsc picture emlmsc  路  3Comments

smmoosavi picture smmoosavi  路  3Comments

paulevmo picture paulevmo  路  3Comments

clenondavis picture clenondavis  路  3Comments