angular / angular/components

bug(button-toggle): Mixin does not support color variants

未关闭
#29,547 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
docs P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

According to [documentation](https://material.angular.io/guide/theming#using-component-color-variants), the MatButtonToggle component can be stylized using 4 color variants:

> | Component | Supported $color-variant values | Default |
> |--------|--------|--------|
> | Button-toggle | primary, secondary, tertiary, error | secondary |

But when I use the mixin `@include mat.button-toggle-color(theme.$light-theme, $color-variant: primary);` I get the following error:
```
"Invalid color variant: primary. Mixin does not support color variants."

123 │ token-utils.get-tokens-for($tokens, tokens-mat-standard-button-toggle.$prefix, $options...);
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

node_modules\@angular\material\button-toggle\_button-toggle-theme.scss 123:7 -theme-from-tokens()
node_modules\@angular\material\button-toggle\_button-toggle-theme.scss 38:5 color()
src\styles.scss 36:2 root stylesheet
```

### Reproduction

Setup a regular Material 3 project and copy/paste:
```
@use '@angular/material' as mat;

:root {
@include mat.button-toggle-theme($theme);
@include mat.button-toggle-color($theme, $color-variant: primary);
}

```
Replace `$theme` with a M3 theme.

### Expected Behavior

All styles for color variant should be included.

### Actual Behavior

Error is thrown.

### Environment

- Angular: 18.1.3
- CDK/Material: 18.1.3

贡献指南

打开贡献指南

调研方向

先从 stack trace 中显示的 button-toggle color() mixin 和 _button-toggle-theme.scss 位置开始,然后使用 src/styles.scss 重现 issue 中的 M3 设置。跟踪 $color-variant 选项的验证方式。完成的标准是 primary 变体能够编译,并且包含预期的 button-toggle 样式,同时不出现 invalid-variant 错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, sass
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。