question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS styling does not work with ToolkitProvider

See original GitHub issue

When I use ToolkitProvider, table styling does not work at all. I specified “striped” and “bordered”, but it doesn’t work. I tried applying my own custom rowStyle as well, but it doesn’t work. It’s as if the CSS doesn’t exist. Search bar styling does not work either. Here is my code:

import React, { Component } from 'react'
import 'react-bootstrap-table-next/dist/react-bootstrap-table2.min.css'
import 'react-bootstrap-table2-toolkit/dist/react-bootstrap-table2-toolkit.min.css'
import dataArr from './data/dataArr'
import ToolkitProvider, { Search } from 'react-bootstrap-table2-toolkit'
import BootstrapTable from 'react-bootstrap-table-next'
import paginationFactory from 'react-bootstrap-table2-paginator'

class IndexTable extends Component {
  constructor (props) {
    super(props)
    this.state = {
      data: dataArr
    }

    this.formatImage = this.formatImage.bind(this)
  }
...
...
...
render () {
    const { SearchBar } = Search
    const columns = [ ....... ]
    ...
    ...
    return (
      <div>
        <ToolkitProvider
          keyField="id"
          data={this.state.data}
          columns={columns}
          bootstrap4
          striped
          bordered
          search
        >
          {
            props => (
              <div>
                <SearchBar {...props.searchProps}
                  placeholder="Search..."
                />
                <hr />
                <BootstrapTable pagination={paginationFactory()} { ...props.baseProps } />
                <br />
              </div>
            )
          }
        </ToolkitProvider>
      </div>
    )
  }
}

I’m running versions: react-bootstrap-table-next: 1.4.1 react-bootstrap-table2-paginator: 1.0.4 react-bootstrap-table2-toolkit: 1.1.1

Thank you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
zawebcommented, Nov 13, 2018

I tried it that way but it didn’t work. What I ended up doing is adding “import ‘bootstrap/dist/css/bootstrap.css’” before the table2 CSS. Now it appears to work. Thanks!

On Tue, Nov 13, 2018 at 4:38 PM Yassien notifications@github.com wrote:

The reason striped and bordered are not working is because you have to pass them to the <BootstrapTable/> component not the <ToolkitProvider/> like so:

<BootstrapTable striped bordered { …props.baseProps }/>

As per the documentation https://react-bootstrap-table.github.io/react-bootstrap-table2/docs/toolkits-getting-started.html you only need to move keyField, data, columns and bootstrap4 props to <ToolkitProvider/>

I tested the <SearchBar/> placeholder and it’s working fine, and you didn’t provide any code for the rowStyle. I could test the styling if you provide the code 😃

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/react-bootstrap-table/react-bootstrap-table2/issues/662#issuecomment-438447560, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7LL09qIw3eRvccSlQPw4TtvVxEQen6ks5uuzvXgaJpZM4YYMbQ .

0reactions
mihael-stormragecommented, May 24, 2021

Have this or kinda alike issue on Export CSV btn:

image

import 'bootstrap/dist/css/bootstrap.min.css';
import 'react-bootstrap-table-next/dist/react-bootstrap-table2.min.css';
import 'react-bootstrap-table2-toolkit/dist/react-bootstrap-table2-toolkit.min.css';
// ...
<ToolkitProvider keyField="id" data={employees} columns={columns} bootstrap4 exportCSV>
  {({ baseProps, csvProps }) => (
    <div>
      {/* eslint-disable-next-line react/jsx-props-no-spreading */}
      <ExportCSVButton {...csvProps}>Export CSV</ExportCSVButton>
      <hr />
      <BootstrapTable
        /* eslint-disable-next-line react/jsx-props-no-spreading */
        {...baseProps}
        filter={filterFactory()}
        filterPosition
      />
    </div>
  )}
</ToolkitProvider>

UPD: Probably not a bug, fixed by adding className="btn-success"

Read more comments on GitHub >

github_iconTop Results From Across the Web

React ToolkitProvider BootstrapTable4 - css - Stack Overflow
I assume that basic style will be applied to header row, and data rows (padding, margin, font-size and font-family as examples).
Read more >
CSS @media Rule - W3Schools
The @media rule is used in media queries to apply different styles for different media types/devices. Media queries can be used to check...
Read more >
Columns Props · react-bootstrap-table2
A new Object will be the result of element style. column.headerStyle - [Object | Function]. It's available to have customized inline-style on table...
Read more >
@ounai/react-bootstrap-table2-toolkit - npm
ToolkitProvider is a wrapper of react context, you are supposed to wrap the BootstrapTable and SearchBar as the child of ToolkitProvider.
Read more >
react-bootstrap-table-next - basic example - CodeSandbox
react-bootstrap-table-next - basic example. brohera. 602. 0. 3. Edit Sandbox. Files. public. src. index.js. styles.css. package.json. Dependencies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found