简体   繁体   中英

How to create different styles for different React Tables?

We have a web app where we use React Table ( https://react-table.js.org ). We have overridden the original React Table's CSS file in the following way (we have scss file):

@import '~react-table/react-table.css';

.ReactTable {
    border: none;

    .rt-noData {
        z-index: auto;
        top: calc(50% + 20px);
    }

    .rt-thead {
        &.-header {
            box-shadow: none;
            border-bottom: solid 1px #dddddd;
            border-top: solid 1px #dddddd;

            .row {
                display: flex;
            }
    ...

And, of course, all our tables have the same style. But, I need to style some tables in different way that is some of settings are the same, and some of them are not.

How to do that?

You could add a div parent with css for changing the styles, for example wrap your ReactTable in <div className="custom-table"></div> and then:

 .custom-table // -> for custom table
  .ReactTable {
    border: none;

    .rt-noData {
        z-index: auto;
        top: calc(50% + 20px);
    }

    ...


  .ReactTable { // -> for default table
    border: none;

    .rt-noData {
        z-index: auto;
        top: calc(50% + 20px);
    }

    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM