Skip to content

fix(button): primaryColor and dangerColor tokens not working with sol…#55934

Merged
yoyo837 merged 5 commits intoant-design:masterfrom
tuzixiangs:fix/issue-55931-button-token-solid-variant
Dec 3, 2025
Merged

fix(button): primaryColor and dangerColor tokens not working with sol…#55934
yoyo837 merged 5 commits intoant-design:masterfrom
tuzixiangs:fix/issue-55931-button-token-solid-variant

Conversation

@tuzixiangs
Copy link
Copy Markdown
Contributor

@tuzixiangs tuzixiangs commented Nov 26, 2025

English Template / 英文模板

🤔 这个变动的性质是?

  • 🆕 新特性提交
  • 🐞 Bug 修复
  • 📝 站点、文档改进
  • 📽️ 演示代码改进
  • 💄 组件样式/交互改进
  • 🤖 TypeScript 定义更新
  • 📦 包体积优化
  • ⚡️ 性能优化
  • ⭐️ 功能增强
  • 🌐 国际化改进
  • 🛠 重构
  • 🎨 代码风格优化
  • ✅ 测试用例
  • 🔀 分支合并
  • ⏩ 工作流程
  • ⌨️ 无障碍改进
  • ❓ 其他改动(是关于什么的改动?)

🔗 相关 Issue

Closes #55931
Closes #55959

💡 需求背景和解决方案

问题描述

  1. Issue Button: defaultColor, primaryColor and dangerColor tokens don't work in v6 #55931: primaryColordangerColor Token 在 solid 变体下不生效。
  2. Issue Button: defaultHoverBg and defaultActiveBg tokens don't work in v6 #55959: defaultHoverBgdefaultActiveBg Token 在 outlineddashed 变体下不生效。

解决方案

  1. variant.ts 中,为 Primary 和 Danger 颜色变体添加 Solid 样式覆盖,使其能够正确应用 primaryColordangerColor Token。
  2. variant.ts 中,为 Outlined 和 Dashed 变体添加背景色覆盖,使其能够正确应用 defaultHoverBgdefaultActiveBg Token。

📝 更新日志

语言 更新描述
🇺🇸 英文 Fix Button tokens (primaryColor, dangerColor, defaultHoverBg, defaultActiveBg) not working with specific variants (solid, outlined, dashed).
🇨🇳 中文 修复 Button 组件部分 Token(primaryColor, dangerColor, defaultHoverBg, defaultActiveBg)在特定变体(solid, outlined, dashed)下不生效的问题

…id variant

- Add text color override for primary solid variant
- Add text color override for danger solid variant
- Align implementation with default button pattern
- Add demo test case for token customization
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 26, 2025

Preview is ready

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 26, 2025

👁 Visual Regression Report for PR #55934 Failed ❌

🎯 Target branch: master (b2f0595)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 3 changed

Expected (Branch master) Actual (Current PR) Diff
button-debug-color-variant.compact.png button-debug-color-variant.compact.png button-debug-color-variant.compact.png button-debug-color-variant.compact.png
button-debug-color-variant.dark.png button-debug-color-variant.dark.png button-debug-color-variant.dark.png button-debug-color-variant.dark.png
button-debug-color-variant.default.png button-debug-color-variant.default.png button-debug-color-variant.default.png button-debug-color-variant.default.png

Important

There are 3 diffs found in this PR: 🔄 3 changed.
Please check all items:

  • Visual diff is acceptable

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 26, 2025

📝 Walkthrough

Summary by CodeRabbit

发布说明

  • 新功能

    • 新增按钮主题色彩自定义配置能力,支持对不同按钮状态下的文字和背景颜色进行精细调整
  • 样式

    • 优化 solid 实心按钮在主色和危险色主题下的文字颜色表现
    • 改进 outlined 描边和 dashed 虚线按钮在悬停及激活状态下的背景颜色显示

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

为 Button 组件引入了主题示例文件并在样式层对变体(solid/outlined/dashed)添加显式文本色与悬停/激活态处理,以恢复并支持 primaryColor、dangerColor、defaultColor 等主题令牌的生效。

Changes

内聚组块 / 文件(s) 变更摘要
演示与主题示例
components/button/demo/debug-color-variant.tsx
新增演示文件:引入 type { ThemeConfig },定义 const theme: ThemeConfig = { ... }(包含 defaultHoverBg, defaultActiveBg, primaryColor, dangerColor 等),并在 ConfigProvider 中渲染多种按钮(type="primary" variant="solid", color="primary" variant="solid", color="danger" variant="solid" 以及默认/outlined/dashed 示例)。
样式变体调整
components/button/style/variant.ts
在样式中为纯色(solid)变体添加显式文本颜色覆盖,分别在 primary 与 danger 颜色块中通过嵌套选择器(&{componentCls}-variant-solid)设置文本色及其悬停/激活态;在默认色块中为 outlined/dashed 变体添加 hover/active 背景处理;确保令牌(如 primaryColor/dangerColor/defaultColor)在 v6 中可被映射并生效。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 分钟

  • 重点检查 components/button/style/variant.ts 中对 CSS 变量与设计令牌的引用是否与全局主题令牌一致,避免覆盖不当或选择器优先级问题。
  • 验证 components/button/demo/debug-color-variant.tsx 中的 ThemeConfig 配置项名与 antd 主题系统字段完全匹配,确保演示能反映真实令牌替换效果。
  • 测试场景:默认按钮、primary solid、danger solid、outlined、dashed 在常态/hover/active 下颜色是否符合预期。

🐰 兔子画了个色环,
按钮换上新衣衫,
粉绿耀眼又分明,
悬停激活皆相随,
主题生效乐开颜 ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰准确地反映了主要变更——修复primaryColor和dangerColor令牌在solid变体中不起作用的问题。
Linked Issues check ✅ Passed 代码变更完全满足#55931中的需求:为Primary和Danger颜色变体的solid样式添加了文本颜色覆盖,使primaryColor和dangerColor令牌能够正确生效。
Out of Scope Changes check ✅ Passed 所有变更都在#55931的范围内:在variant.ts中为solid变体添加颜色令牌支持,在demo中添加测试用例以验证修复。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR description clearly describes bug fixes for Button component tokens not working with solid, outlined, and dashed variants, with specific issue references and changelog entries.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @tuzixiangs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求解决了 Ant Design v6 中 Button 组件的一个样式问题。它确保通过 ConfigProvider 配置的自定义主色和危险色能够正确应用于实心(solid variant)按钮,从而使用户能够自定义这些按钮的文本颜色。

Highlights

  • Bug 修复: 修复了 Ant Design v6 中 Button 组件在使用 variant="solid" 时,primaryColordangerColor token 不生效的问题。
  • 解决方案: 为 Primary 和 Danger 颜色变体添加 Solid 样式覆盖,使其能够正确应用 primaryColordangerColor token,与 Default 按钮的实现模式保持一致。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 Pull Request 旨在修复 Ant Design v6 中 Button 组件 variant="solid" 状态下 primaryColordangerColor token 不生效的问题。您通过在 primarydanger 颜色变体的样式中为 solid 变体添加特定的 text-color 覆盖来解决此问题,使其能够正确应用 ConfigProvider 中配置的 primaryColordangerColor token。这个改动是正确的,并且与 default 按钮的实现方式保持了一致。此外,您还添加了一个新的演示页面 debug-color-variant.tsx 来验证修复效果,这是一个很好的实践。

我的评审意见主要集中在 components/button/style/variant.ts 文件中,我发现新添加的部分代码存在一些可以简化的地方,以提高代码的简洁性和可维护性。具体细节请查看我的评论。

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/button/demo/debug-color-variant.tsx (1)

1-4: import 顺序可以稍微整理一下(可选)

功能上完全没问题,但从项目约定看,demo 推荐的导入顺序是:React → 依赖 → antd 组件 → 自定义组件 → types → styles。这里 antd-style 作为依赖,理论上可以放在 antd 之前,同时把 ThemeConfig 的类型导入与 antd 相关导入放到一起,会更统一一些。不过这只是风格层面的优化,不影响合并。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09d9a92 and 213a087.

📒 Files selected for processing (2)
  • components/button/demo/debug-color-variant.tsx (3 hunks)
  • components/button/style/variant.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always use TypeScript with strict type checking
Never use any type - define precise types instead
Use interfaces (not type aliases) for object structures
Export all public interface types
Prefer union types over enums, use as const for constants
Use early returns to improve readability
Support tree shaking
Follow import order: React → dependencies → antd components → custom components → types → styles
Prefer antd built-in components over external dependencies
Pass all ESLint and TypeScript checks
No console errors or warnings

**/*.{ts,tsx}: Use camelCase for property names
All components and functions must provide accurate type definitions
Avoid using any type, define types as precisely as possible
Use interface rather than type alias for defining object structures
All TypeScript should compile without errors or warnings
Use generics appropriately to enhance type flexibility
Use intersection types (&) to merge multiple types
Use literal union types to define limited option sets
Avoid using enum, prefer union types and as const
Rely on TypeScript's type inference as much as possible
Use type assertions (as) only when necessary
Complex data structures should be split into multiple interface definitions
Avoid outdated APIs and keep updated to new recommended usage

Files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
components/**/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/**/*.tsx: Component props interfaces should be named ComponentNameProps
Component ref types should use React.ForwardRefRenderFunction
Use functional components with hooks exclusively (no class components)
Apply performance optimizations with React.memo, useMemo, useCallback appropriately
Support server-side rendering
Components must support ref forwarding with structure including nativeElement, focus, and other methods
Use PascalCase for component names
Use camelCase for props with specific patterns: default + PropName for defaults, forceRender for force rendering, open instead of visible for panel state, show + PropName for display toggles, PropName + able for capabilities, dataSource for data source, disabled for disabled state, extra for additional content, icon for icons, trigger for triggers, className for CSS classes
Use on + EventName pattern for event handlers (e.g., onClick, onChange)
Use on + SubComponentName + EventName pattern for sub-component events
Use complete names, never abbreviations in prop naming
Optimize for minimal re-renders
Use useLocale hook from components/locale/index.tsx
Support accessibility (WCAG 2.1 AA)

Files:

  • components/button/demo/debug-color-variant.tsx
components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Never hardcode colors, sizes, or spacing values

components/**/*.{ts,tsx}: Use TypeScript and React for component development
Use functional components and hooks, avoid class components
Use PascalCase for component names
Use complete names rather than abbreviations in component naming
Initialize properties should use default + PropName naming pattern
Panel opening should use open prop instead of visible
Event handlers should follow on + EventName naming pattern
Child component events should follow on + SubComponentName + EventName naming pattern
Components should provide a ref attribute with nativeElement and focus methods
Export all public interface types for user convenience
Component props should use interface definition named ComponentNameProps
Use CSS transitions for simple animations, rc-motion for complex animations
Respect user's prefers-reduced-motion setting for animations
Follow WCAG 2.1 AA level accessibility standards for styling
Achieve 100% test coverage
Use useLocale hook from components/locale/index.tsx to get localization configuration
Use React.memo, useMemo, and useCallback appropriately for performance optimization
Use React.ForwardRefRenderFunction for component ref types
Callback function types should have explicit parameter and return value definitions
Component state should have dedicated interfaces (e.g., ComponentNameState)
Components should display well on different screen sizes (responsive design)
Components should support right-to-left (RTL) reading direction
Support page zoom to 200% with normal layout
Avoid animations that cause flickering
Ensure code runs normally with no console errors
Avoid unnecessary re-renders
Support Tree Shaking for bundle optimization

Files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
components/*/demo/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/*/demo/*.tsx: Keep demo code concise and copy-pasteable
Focus each demo on a single feature
Use kebab-case for demo filenames: basic.tsx, custom-filter.tsx

Files:

  • components/button/demo/debug-color-variant.tsx
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 2-space indentation

Files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Maintain cross-browser compatibility

Files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js}: Use early returns to improve code readability
Pass all ESLint and TypeScript checks

Files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
components/**/demo/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

components/**/demo/*.tsx: Demo code should be concise and suitable for users to copy directly into their projects
Each demo should focus on demonstrating one feature point
Demo files should be named with lowercase hyphen-separated words (e.g., basic.tsx, custom-filter.tsx)
Demo code import order: React → dependencies → antd components → custom components → types → styles
Demo code should use 2-space indentation, arrow functions, and camelCase naming
Arrange demos from simple to complex

Files:

  • components/button/demo/debug-color-variant.tsx
components/**/style/*.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/**/style/*.ts: Use @ant-design/cssinjs for all styling
Generate styles with functions named gen[ComponentName]Style
Use design tokens from the Ant Design token system
Support both light and dark themes
Use CSS logical properties for RTL support (e.g., margin-inline-start instead of margin-left)
Respect prefers-reduced-motion for animations

Files:

  • components/button/style/variant.ts
components/**/style/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Component Token naming format should follow: variant (optional) + semantic part + semantic part variant (optional) + css property + size/disabled (optional)

Files:

  • components/button/style/variant.ts
components/**/style/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

components/**/style/**/*.{ts,tsx}: Use @ant-design/cssinjs as the styling solution
Style generation functions should follow gen[ComponentName]Style naming convention
Use CSS-in-JS with performance considerations, avoid unnecessary style recalculation
Use class selectors instead of tag selectors for style overrides to improve specificity
Use CSS logical properties (margin-inline-start) instead of directional properties (margin-left) for RTL support
Ensure sufficient color contrast and do not rely on color alone to convey information
Components should use global Tokens and component-level Tokens for styling
Avoid hardcoding colors, sizes, spacing values; use design Tokens instead
Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)
Token modifications should cascade downward to ensure design system consistency
All components must support dark mode
Provide clear visual indication for focus state

Files:

  • components/button/style/variant.ts
🧠 Learnings (25)
📓 Common learnings
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Use design tokens from the Ant Design token system
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Avoid hardcoding colors, sizes, spacing values; use design Tokens instead
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/demo/*.tsx : Demo code import order: React → dependencies → antd components → custom components → types → styles

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Avoid hardcoding colors, sizes, spacing values; use design Tokens instead

Applied to files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Ensure sufficient color contrast and do not rely on color alone to convey information

Applied to files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Support both light and dark themes

Applied to files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)

Applied to files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Use design tokens from the Ant Design token system

Applied to files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/*.{ts,tsx} : Never hardcode colors, sizes, or spacing values

Applied to files:

  • components/button/demo/debug-color-variant.tsx
  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/demo/*.tsx : Arrange demos from simple to complex

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/*/demo/*.tsx : Focus each demo on a single feature

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/*/demo/*.tsx : Keep demo code concise and copy-pasteable

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Use `ant-design/cssinjs` as the styling solution

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/style/*.ts : Use `ant-design/cssinjs` for all styling

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T10:42:01.303Z
Learnt from: Wxh16144
Repo: ant-design/ant-design PR: 55810
File: .dumi/theme/common/VersionUpgrade/ChangeLog.tsx:69-71
Timestamp: 2025-11-24T10:42:01.303Z
Learning: In Ant Design's `.dumi/theme/` documentation and theme files, browser compatibility considerations are less strict than in the component library itself. Native APIs like ResizeObserver can be used directly without requiring polyfills or wrapper packages that are used in the main components.

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to **/*.{ts,tsx} : Prefer antd built-in components over external dependencies

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-13T02:52:08.942Z
Learnt from: meet-student
Repo: ant-design/ant-design PR: 55697
File: components/drawer/index.tsx:86-88
Timestamp: 2025-11-13T02:52:08.942Z
Learning: In Ant Design components (components/**/*.{ts,tsx}), always use `import useId from 'rc-util/lib/hooks/useId'` instead of `React.useId()` for generating unique IDs, to ensure compatibility with React 16-19. The rc-util hook automatically uses the native implementation in React 18+ and provides a fallback for older versions.

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Use CSS-in-JS with performance considerations, avoid unnecessary style recalculation

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : All components must support dark mode

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/*.{ts,tsx} : Use TypeScript and React for component development

Applied to files:

  • components/button/demo/debug-color-variant.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/*.{ts,tsx} : Component Token naming format should follow: `variant (optional)` + `semantic part` + `semantic part variant (optional)` + `css property` + `size/disabled (optional)`

Applied to files:

  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Token modifications should cascade downward to ensure design system consistency

Applied to files:

  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Use class selectors instead of tag selectors for style overrides to improve specificity

Applied to files:

  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Provide clear visual indication for focus state

Applied to files:

  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/*.{ts,tsx} : Follow WCAG 2.1 AA level accessibility standards for styling

Applied to files:

  • components/button/style/variant.ts
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/style/**/*.{ts,tsx} : Components should use global Tokens and component-level Tokens for styling

Applied to files:

  • components/button/style/variant.ts
🧬 Code graph analysis (1)
components/button/demo/debug-color-variant.tsx (1)
components/badge/demo/component-token.tsx (1)
  • ConfigProvider (6-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: size
  • GitHub Check: build
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: lint
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: test-node
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: build
  • GitHub Check: build preview
🔇 Additional comments (2)
components/button/demo/debug-color-variant.tsx (1)

50-57: ThemeConfig 使用合理,新示例很好覆盖修复场景

  • theme 声明为 ThemeConfig 能保证在配置 components.Button.primaryColor / dangerColor 时有完整类型提示,符合 ConfigProvider 的推荐用法。
  • 新增的 “theme config” 区块同时覆盖:
    • type="primary" variant="solid"
    • color="primary" variant="solid"
    • color="danger" variant="solid"
      这正好对应 issue 中 solid 变体不可通过组件级 token 自定义文字颜色的问题,便于本地回归和后续排查。
  • 配置值使用简单颜色字符串('pink' / 'green')在 debug/demo 场景是合理的,和 Badge 的 component token demo 方式保持一致。

这部分我没有发现需要修改的问题。

Also applies to: 101-114

components/button/style/variant.ts (1)

167-200: primary / danger 的 solid 文本颜色覆盖方式正确,符合 token 设计

  • &${componentCls}-color-primary / &${componentCls}-color-dangerous 内增加 &${componentCls}-variant-solid,将 text-color 分别绑定到 token.primaryColortoken.dangerColor,并让 hover / active 都回落到同一 CSS 变量,这样 ConfigProvider 中的组件级 token 就能精确控制 solid 按钮文字颜色,而不再被全局的 colorTextLightSolid 覆盖。
  • 颜色块写在 Variants 块之后,选择器也更具体(.ant-btn-color-xxx.ant-btn-variant-solid),因此在 CSS 级联中可以可靠地覆写通用 solid 变量。
  • 新代码完全使用 Button 相关 token,没有引入新的硬编码颜色,符合组件样式使用 token 而非魔法值的要求。Based on learnings.

整体来看,这段修改实现简洁、方向正确,我这边没有其他阻塞意见。

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 26, 2025

Bundle Report

Changes will increase total bundle size by 2.61kB (0.07%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.89MB 2.61kB (0.07%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 1.3kB 2.14MB 0.06%
antd.min.js 1.3kB 1.75MB 0.07%

…id variant

- Add text color override for primary solid variant
- Add text color override for danger solid variant
- Align implementation with default button pattern
- Add demo test case for token customization
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b2f0595) to head (11850e0).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #55934   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          803       803           
  Lines        14831     14831           
  Branches      3916      3916           
=========================================
  Hits         14831     14831           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pareder
Copy link
Copy Markdown
Contributor

Pareder commented Dec 3, 2025

@tuzixiangs @meet-student What is left to do for this PR to be merged?

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Dec 3, 2025
@yoyo837 yoyo837 merged commit 25a37ed into ant-design:master Dec 3, 2025
38 checks passed
@dosubot dosubot Bot mentioned this pull request Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button: defaultHoverBg and defaultActiveBg tokens don't work in v6 Button: defaultColor, primaryColor and dangerColor tokens don't work in v6

4 participants