react-bootstrap-table / react-bootstrap-table2

Next Generation of react-bootstrap-table
https://react-bootstrap-table.github.io/react-bootstrap-table2/
MIT License
1.26k stars 430 forks source link

css modules with BootstrapTable? #1313

Open reposman33 opened 4 years ago

reposman33 commented 4 years ago

Question I use react-bootstrap-table-next": "^4.0.0. Have set up a BootstrapTable and use the classes prop to style it. That works fine but I want to use use css modules since it is super easy in React > 16.8:

When using create-react-app I have 2 options to reference styles in an external stylesheet:

plain scsss:

import './styleSheet.scsss';
...
<table className="myTableclass">

CSS modules:

import * as styles from './styleSheet.module.scsss';
...
<table className={styles.myTableclass}>

The BootstrapTable docs have minimal information on this. All it says is

classes - [String]

So only the first options is covered. Can I use the 2nd options, CSS modules?

jonathanrodriguezs commented 4 years ago

Hi @reposman33, yes, you can use CSS modules because practically they are strings with the class name you declared in your stylesheet plus a hash as an identifier to avoid naming conflicts.

CSS Modules allows the scoping of CSS by automatically creating a unique classname of the format [filename]_[classname]__[hash].

https://create-react-app.dev/docs/adding-a-css-modules-stylesheet/