Overriding Styles in Material UI in React

若如初见. 提交于 2021-02-16 20:27:33

问题


I have a problem overriding the styles in my theme in Material UI in React. I wanted to customize the border of columnsContainer but it isn't working. only the root is working well.

Check Here for Codesanbox

MuiDataGrid.js

export default {
  root: {
    backgroundColor: "white",
    border: `1px solid green`,
    "& .columnsContainer": {
      borderBottom: `1px solid 'blue' !important`
    }
  }
};

回答1:


Below is the correct syntax. The changes compared to your code sandbox are:

  1. Replace .columnsContainer with .MuiDataGrid-columnsContainer
  2. Correct the borderBottom syntax to be 1px solid blue instead of 1px solid 'blue' !important.
export default {
  root: {
    backgroundColor: "white",
    border: `1px solid green`,
    "& .MuiDataGrid-columnsContainer": {
      borderBottom: `1px solid blue`
    }
  }
};



来源:https://stackoverflow.com/questions/64726379/overriding-styles-in-material-ui-in-react

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!