最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I style React-Table? - Stack Overflow

programmeradmin5浏览0评论

I am using react-table to create a filterable table, however I wanted to style it the way I want. Should I change it directly inside node_modules application or should I create my own CSS file and override inspecting the element on the fly?

I am using react-table to create a filterable table, however I wanted to style it the way I want. Should I change it directly inside node_modules application or should I create my own CSS file and override inspecting the element on the fly?

Share Improve this question asked Dec 18, 2018 at 21:51 Jeff GoesJeff Goes 5553 gold badges8 silver badges22 bronze badges 1
  • can you review answers? I styled React-Table in a couple of apps and am happy to help you out. – acidjunk Commented Apr 26, 2019 at 22:04
Add a comment  | 

3 Answers 3

Reset to default 8

For React-Table v6, you can basically do it in 2 ways if you want to use css files.

  1. Start with the css file from the npm package and override pieces you want to change

  2. Start with your own css file and style everything that needs to be styled

Ad 1:

import "react-table/react-table.css"
import "./your_own_styles.(s)css"

Ad 2:

import "./your_own_styles.(s)css"

To get an idea what you can use in your own css file you can have a look at this gist: https://gist.github.com/sghall/380aa1055bcad4db22d1fc258d7f09d0

Or start by copying the react-table/react-table.css from the react-table npm package (in your node_modules).

Definitely do not change the node_modules. You can either style inline or attach styles.

https://reactjs.org/docs/faq-styling.html

Definitely override the CSS classes with your own file. That's common practice for styling components from libraries.

发布评论

评论列表(0)

  1. 暂无评论