Theme

超级容易更换主题颜色、字体和圆角。

使用

  1. document.body.style.setProperty('--mdc-theme-primary', 'red')
  2. document.body.style.setProperty('--mdc-theme-secondary', 'blue')
  3. document.body.style.setProperty('--mdc-theme-error', 'yellow')

所有配置:

  1. --mdc-theme-primary: #0072d9;
  2. --mdc-theme-secondary: #2170b8;
  3. --mdc-theme-error: #f5222d;
  4. --mdc-theme-surface: #ffffff;
  5. --mdc-theme-on-primary: #ffffff;
  6. --mdc-theme-on-secondary: #ffffff;
  7. --mdc-theme-on-error: #ffffff;
  8. --mdc-theme-on-surface: #000000;
  9. --mdc-theme-background: #ffffff;
  10. --mdc-shape-small-component-radius: 4px;
  11. --mdc-shape-medium-component-radius: 4px;
  12. --mdc-shape-large-component-radius: 0px;
  13. --mdc-typography--font-family: Roboto, sans-serif;

REPL 的实现代码

  1. <m-color-picker id='picker' save="0" default="ecb89a" preview="0" button='0' clear='0' width="300px">
  2. </m-color-picker>
  3. <script>
  4. document.body.style.setProperty('--mdc-theme-primary', '#ecb89a')
  5. var picker = document.querySelector('#picker')
  6. picker.addEventListener('change', function (evt) {
  7. document.body.style.setProperty('--mdc-theme-primary', evt.detail.color)
  8. })
  9. </script>