aliyunTheme在线预览 https://theme.antd.group/aliyun
文档 https://github.com/ant-design/ant-design-aliyun-theme
image.png

  1. yarn add @ant-design/aliyun-theme
  2. import aliyunTheme from '@ant-design/aliyun-theme';
  3. // config.js & .umirc.js & .umirc.ts
  4. export default {
  5. "theme": aliyunTheme,
  6. }
  7. // less变量
  8. @import "~@ant-design/aliyun-theme/index.less";

image.png
看到默认的按钮样式和颜色改变,就代表aliyunTheme主题配置成功了

aliyunTheme变量

image.png

  1. {
  2. default: {
  3. '@font-size-sm': '12px',
  4. '@font-size-base': '12px',
  5. '@primary-color': '#0070cc',
  6. '@border-radius-base': '0',
  7. '@border-radius-sm': '0',
  8. '@text-color': 'fade(#000, 65%)',
  9. '@text-color-secondary': 'fade(#000, 45%)',
  10. '@background-color-base': 'hsv(0, 0, 96%)',
  11. '@success-color': '#1e8e3e',
  12. '@error-color': '#d93026',
  13. '@warning-color': '#ffc440',
  14. '@info-color': '@primary-color',
  15. '@danger-color': '@error-color',
  16. '@processing-color': '@primary-color',
  17. '@border-color-base': '#dedede',
  18. '@border-color-split': '#dedede',
  19. '@outline-width': '0',
  20. '@outline-color': '#737373',
  21. '@input-height-lg': '36px',
  22. '@input-height-base': '32px',
  23. '@input-height-sm': '24px',
  24. '@input-hover-border-color': '#737373',
  25. '@form-item-margin-bottom': '16px',
  26. '@btn-default-bg': '#fafafa',
  27. '@btn-default-border': '#dedede',
  28. '@btn-danger-color': '#fff',
  29. '@btn-danger-bg': '@error-color',
  30. '@btn-danger-border': '@error-color',
  31. '@switch-color': '@success-color',
  32. '@table-header-bg': '#fafafa',
  33. '@table-row-hover-bg': '#fafafa',
  34. '@table-padding-vertical': '15px',
  35. '@badge-color': '@error-color',
  36. '@breadcrumb-base-color': '@text-color',
  37. '@breadcrumb-last-item-color': '@text-color-secondary',
  38. '@slider-rail-background-color': '@background-color-base',
  39. '@slider-rail-background-color-hover': '#e1e1e1',
  40. '@slider-track-background-color': '@primary-color',
  41. '@slider-track-background-color-hover': '@primary-color',
  42. '@slider-handle-border-width': '1px',
  43. '@slider-handle-color': '#dedede',
  44. '@slider-handle-color-hover': '#dedede',
  45. '@slider-handle-color-focus': '#dedede',
  46. '@slider-handle-color-tooltip-open': '#ddd',
  47. '@slider-handle-color-focus-shadow': 'transparent',
  48. '@slider-handle-shadow': '1px 1px 4px 0 rgba(0,0,0,.13)',
  49. '@alert-success-border-color': '#dff4e5',
  50. '@alert-success-bg-color': '#dff4e5',
  51. '@alert-info-border-color': '#e5f3ff',
  52. '@alert-info-bg-color': '#e5f3ff',
  53. '@alert-error-border-color': '#fcebea',
  54. '@alert-error-bg-color': '#fcebea',
  55. '@alert-warning-border-color': '#fff7db',
  56. '@alert-warning-bg-color': '#fff7db',
  57. '@radio-button-bg': 'transparent',
  58. '@radio-button-checked-bg': 'transparent',
  59. '@progress-radius': '0',
  60. '@tabs-card-gutter': '-1px',
  61. '@tabs-card-tab-active-border-top': '2px solid @primary-color',
  62. '@layout-body-background': '#fafafa'
  63. }
  64. }

custom-theme.js

  1. {
  2. '@primary-color': '#1677ff',
  3. '@normal-color': '#dbdfe8',
  4. '@black': '#001234',
  5. '@font-family': `opensans, -apple-system, blinkmacsystemfont, 'segoe ui', roboto, 'helvetica neue', arial, 'noto sans', sans-serif, 'apple color emoji', 'segoe ui emoji', 'segoe ui symbol'`,
  6. '@item-hover-bg': '#f3f7fc',
  7. '@border-color-base': '#dbdfe8',
  8. '@border-color-split': '#f0f2f6',
  9. '@background-color-light': '#fafbfc',
  10. '@background-color-base': '#f5f6f9',
  11. '@disabled-color': 'rgba(4,15,36,0.25)',
  12. '@descriptions-bg': '#fafbfc',
  13. '@divider-color': 'rgba(0, 34, 101, 6%)',
  14. '@btn-font-weight': 600,
  15. '@btn-shadow': '0 2px 0 rgba(4, 15, 36, 0.04)',
  16. '@btn-primary-shadow': '0 4px 8px 0 rgba(22,119,255,0.24)',
  17. '@btn-text-shadow': '0 0px 0 rgba(0, 0, 0, 0.001)',
  18. '@btn-text-hover-bg': 'rgba(0, 34, 101, 0.018)',
  19. '@input-number-handler-active-bg': '#f5f6f9',
  20. '@select-multiple-item-disabled-color': '#bfc8d8',
  21. '@tooltip-max-width': '336px',
  22. '@tooltip-color': 'rgba(4,15,36,0.85)',
  23. '@tooltip-bg': '#fff',
  24. '@progress-steps-item-bg': '#f3f7fc',
  25. '@image-bg': '#f3f7fc',
  26. '@layout-body-background': '#f3f7fc',
  27. '@table-body-sort-bg': '#fafbfc',
  28. '@table-expanded-row-bg': '#fafbfc',
  29. '@table-header-cell-split-color': 'rgba(0, 34, 101, 0.06)',
  30. '@table-header-sort-active-bg': 'rgba(0, 34, 101, 0.04)',
  31. '@table-header-filter-active-bg': 'rgba(0, 34, 101, 0.04)',
  32. '@table-sticky-scroll-bar-bg': 'rgba(0,34,101,0.35)',
  33. '@card-skeleton-bg': 'd9dee8',
  34. '@card-shadow':
  35. '0 1px 2px -2px rgba(0, 34, 101, 0.16), 0 3px 6px 0 rgba(0, 34, 101, 0.12), 0 5px 12px 4px rgba(0, 34, 101, 0.01)',
  36. '@comment-author-time-color': '#d9dee8',
  37. '@comment-action - hover - color': '#5c6370',
  38. '@slider-rail-background-color-hover': '#e0e4ec',
  39. '@skeleton-color': 'rgba(191, 200, 216, 0.2)',
  40. '@avatar-bg': '#d9dee8',
  41. '@page-header-back-color': '#040f24',
  42. };

yarn eject配置主题

config/webpack.cofnig.js
148行,新增 …aliyunTheme.default

  1. const aliyunTheme = require('@ant-design/aliyun-theme');
  2. // 148行新增主题配置
  3. let lessOption = {}
  4. if(preProcessor === 'less-loader') {
  5. lessOption = {
  6. javascriptEnabled: true,
  7. modifyVars: {
  8. ...aliyunTheme.default,
  9. 'primary-color': '#008c8c',
  10. }
  11. }
  12. }

image.png

global.less 变量

https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
全量引入 aliyunTheme主题

  1. @import '~antd/es/style/themes/default.less';
  2. @import "~@ant-design/aliyun-theme/index.less";
  3. // 定义less变量
  4. @font-size-base: 14px;

扩展色板

以 HSL色彩模型为基础

  • Hue 色相
  • Saturation 饱和度
  • Lightness 明度

  • Hue 360°色相,默认每 10°为一个节点,基础色相 36阶

  • Saturation 饱和度范围 0 - 100%,默认所有颜色 100%的饱和度
  • Lightness 明度范围 0 -100%,起始明度为 19%,以 10%递增,最高明度 89%,共8个阶梯

image.png
基础蓝色的色阶

  • 从左到右,第21位色相
  • 从下到上,第3阶明度