Bootstrap: Consider alternative method of styling toggle buttons (don't use data-toggle="buttons" for styling)

Created on 29 Aug 2017  路  4Comments  路  Source: twbs/bootstrap

Ref: https://getbootstrap.com/docs/4.0/components/buttons/#checkbox-and-radio-buttons

As of today we need to add data-toggle="buttons" to get proper styling on check / radio buttons done with inputs + labels. While I totally see how it works perfectly with provided jQuery plugins, it is not very intuitive for people not using jQuery but rather using a framework like Angular or React.

Would you consider another method of styling toggle buttons, for example using a dedicated CSS class (eg. .toggle-buttons)?


I've opened similar issue in the past (#20359) but then closed it as a duplicate of #18874. #18874 in turn got closed as a duplicate of number of other issues without addressing the problem. Hence I'm opening a new issue to start with a "clean slate".

css has-pr v4

Most helpful comment

Using it in our JS is fine, but behavior should be detached from styles. That way you can drop our JS and use your own without styling issues.

All 4 comments

Yeah, this should be a class. I don't think anything else is done via data attributes?

Yeah, this should be a class. I don't think anything else is done via data attributes?

Nope, I didn't bump into other cases where data-* is needed for pure styling purposes. So apart from this particular case we should be all good!

For the reference, the data-toggle="buttons" selector is used today in JS plugin (https://github.com/twbs/bootstrap/blob/78f29d2b3cb9bd888c927e8d50ee6962c2f9d407/js/src/button.js#L31-L32).

Using it in our JS is fine, but behavior should be detached from styles. That way you can drop our JS and use your own without styling issues.

24733 was merged, so closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kamov picture kamov  路  3Comments

fohlsom picture fohlsom  路  3Comments

matsava picture matsava  路  3Comments

cvrebert picture cvrebert  路  3Comments

IamManchanda picture IamManchanda  路  3Comments