首页 > 解决方案 > 为 ANTD 扩展或自定义 LESS Mixins

问题描述

是否可以为 ANTD 扩展或自定义 LESS Mixins?

例如,我希望我的按钮在悬停时变暗(而不是变亮)。查看代码,我看到有一个 mixin 可以做到这一点。

https://github.com/ant-design/ant-design/blob/master/components/button/style/mixin.less#L28-L62

.button-variant-primary(@color; @background) {
  .button-color(@color; @background; @background);

  text-shadow: @btn-text-shadow;
  box-shadow: @btn-primary-shadow;

  &:hover,
  &:focus {
    & when (@theme = dark) {
      .button-color(
        @color; ~`colorPalette('@{background}', 7) `; ~`colorPalette('@{background}', 7) `
      );
    }
    & when not (@theme = dark) {
      .button-color(
        @color; ~`colorPalette('@{background}', 5) `; ~`colorPalette('@{background}', 5) `
      );
    }
  }

我尝试用自己的方法覆盖这个 mixin,并在导入 AntD Less 文件之前和之后放置它,但这没有用。

这可能吗?

标签: cssreactjslessantd

解决方案


推荐阅读