Although this question is kind of too generic, I do understand why it appeared. material-components-web is not very easy to start with. Docs and examples are scarce and sometimes it is hard to understand how to do even basic things.
To be able to compile it with your own custom theme variables you need:
- Setup SASS compilation in your project if you don't have it yet.
- Add npm package "material-components-web" as a dependency.
- In your root SCSS-file configure MDC theme with your colors like this:
@use '@material/theme' with (
$primary: #212121,
$on-primary: #ffffff,
$secondary: #ffc629,
$background: #33333D,
$surface: #ffffff,
$on-surface: #000000
);
- After that you can include rest of the MDC's SCSS like this:
@use 'material-components-web/material-components-web'
- Since you need to customize only CSS, I suggest you reference existing precompiled JS. Otherwise you'll need to configure babel compilation as well.
You can use basic-material-starter-kit as an example.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…