Recently, I have been incorporating Material-UI into my React project to enhance its functionality. However, I encountered an issue where I was unable to customize the scrollbars within the Material-UI components. Here is the CSS code that I was using prior to integrating Material-UI:
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background-color: transparent;
border-radius: 5px;
margin: 5px;
}
::-webkit-scrollbar-thumb {
background-color: #1a1b1c;
border-radius: 5px;
border: solid 2px #282c34;
}
::-webkit-scrollbar-thumb:hover {
background-color: #1a1b1c;
border-radius: 5px;
border: solid 2px #1a1b1c;
}
Upon further investigation, I realized that the CSS styling was being overridden by the default Material-UI styles when using components like <Box/>
or <Drawer/>
. Additionally, I am utilizing <ThemeProvider/>
from Material-UI with the following theme configuration:
export const dark_theme = createTheme({
breakpoints: {
values: {
mobile: 0,
desktop: 1024,
},
},
palette: {
type: "dark",
primary: {
main: "#3f51b5",
contrastText: "#fff",
},
secondary: {
main: "#8700ff",
contrastText: "#fff",
},
background: {
default: "#282c34",
},
},
typography: {
fontFamily: "Poppins",
allVariants: {
color: "white",
},
},
overrides: {},
});
Despite attempting to implement CSS Baseline overrides as suggested in the [Mui documentation](https://mui.com/components/css-baseline/#scrollbars), I wasn't able to achieve the desired outcome. This could be attributed to my limited understanding of Material-UI's styling and the deprecation of CSS Baseline scrollbars.
My question now is, how can I integrate the scrollbar styles shown above into a Material-UI component or theme? Any insights or guidance would be greatly appreciated.