8000
Skip to content

fix(Button): defaultBg, defaultColor, defaultHoverColor and defaultActiveColor token does not work#56238

Merged
zombieJ merged 10 commits intoant-design:masterfrom
ug-hero:fix/button
Jan 30, 2026
Merged

fix(Button): defaultBg, defaultColor, defaultHoverColor and defaultActiveColor token does not work#56238
zombieJ merged 10 commits intoant-design:masterfrom
ug-hero:fix/button

Conversation

@ug-hero
Copy link
Copy Markdown
Contributor
@ug-hero ug-hero commented Dec 16, 2025

中文版模板 / Chinese template

🤔 This is a ...

  • 🐞 Bug fix

🔗 Related Issues

close #56232

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English defaultBg, defaultColor and defaultColor token does not work
🇨🇳 Chinese defaultBg, defaultColor and defaultColor 三个token不生效

@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 Dec 16, 2025

👁 Visual Regression Report for PR #56238 Failed ❌

🎯 Target branch: master (44a4161)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 4 changed

Expected (Branch master) Actual (Current PR) Diff
button-component-token.compact.png button-component-token.compact.png button-component-token.compact.png button-component-token.compact.png
button-component-token.dark.png button-component-token.dark.png button-component-token.dark.png button-component-token.dark.png
button-component-token.default.png button-component-token.default.png button-component-token.default.png button-component-token.default.png
popover-render-panel.compact.png popover-render-panel.compact.png popover-render-panel.compact.png popover-render-panel.compact.png

Important

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

  • Visual diff is acceptable

@github-actions
Copy link
Copy Markdown
Contributor
github-actions bot commented Dec 16, 2025

Preview is ready

@coderabbitai
Copy link
Copy Markdown
Contributor
coderabbitai bot commented Dec 16, 2025
📝 Walkthrough

Summary by CodeRabbit

发布说明

  • 样式改进
    • 优化了按钮轮廓和虚线变体的样式表现,改进了文本颜色和背景容器的映射关系,确保悬停和活跃状态下的视觉一致性。

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

Walkthrough

更新按钮变体的样式令牌映射:为 outlined/dashed 变体及其 Default 色块补充显式文本颜色与背景容器映射,并在 demo 中新增一个使用这些令牌的 ConfigProvider 主题示例;同时对 config-provider 类型声明做了格式化调整(无语义变更)。

Changes

Cohort / File(s) Summary
按钮样式变体令牌修复
components/button/style/variant.ts
将背景容器来源映射为 token.defaultBg ?? token.colorBgContainer;为 &-button-variant-outlined&-button-variant-dashed(及其 Default 色块)新增文本颜色映射:text-colortoken.defaultColortext-color-hovertoken.defaultHoverColortext-color-activetoken.defaultActiveColor,并保留 bg-color-hover/bg-color-active 映射。仅调整样式令牌映射,无导出/签名变更。
示例:新增主题覆盖演示
components/button/demo/component-token.tsx
新增一个 ConfigProvider 主题块,设置 defaultBgdefaultColordefaultHoverColordefaultActiveColortextTextColor 等令牌,并在该主题上下文中渲染 Default、Dashed、Text 按钮以展示效果。
格式化(无功能改动)
components/config-provider/context.ts
PaginationConfigPick<...> 表达式做了换行/格式化调整,未改变被选取的属性或导出签名。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • li-jia-nan

Poem

🐰 小兔轻跳报新章,
令牌换色不慌张,
背景稳固有备援,
文字三态整齐亮,
按钮开花笑声扬。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR标题准确描述了主要改动:修复Button组件中defaultBg、defaultColor、defaultHoverColor和defaultActiveColor token不生效的问题。
Description check ✅ Passed PR描述关联了相关issue(#56232),标记为bug fix,提供了英文和中文的Changelog条目,与变更内容相关。
Linked Issues check ✅ Passed 代码变更修复了issue #56232中报告的问题:在components/button/style/variant.ts中为outlined和dashed variant添加了defaultBg、defaultColor、defaultHoverColor和defaultActiveColor的token映射,demo中也展示了这些token的使用。
Out of Scope Changes check ✅ Passed components/config-provider/context.ts只是格式化调整PaginationConfig类型,components/button/demo/component-token.tsx添加了theme demo展示,均与修复Button token问题的目标相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 @ug-hero, I'm Gemini Code Assis 8000 t1! 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!

This pull request addresses a critical styling bug within the Button component where specific theming tokens, namely defaultBg, defaultColor, and defaultHoverColor, were not being correctly recognized and applied. The changes ensure that the button's background and text colors, especially for outlined and dashed variants, now properly respect the defined default tokens, leading to a more consistent and predictable visual experience across the application.

Highlights

  • Bug Fix: Default Background Token: Resolved an issue where the defaultBg token was not correctly applied to the button's background color container, ensuring it now acts as a proper fallback.
  • Bug Fix: Default Color Tokens for Outlined/Dashed Buttons: Fixed a bug where defaultColor and defaultHoverColor tokens were not being applied to the text color of outlined and dashed button variants, ensuring consistent theming.
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

This pull request correctly fixes an issue where defaultBg, defaultColor, and defaultHoverColor tokens were not being applied correctly for some button variants, which prevented proper theme customization. The changes are well-targeted. I've added one suggestion to also handle defaultActiveColor for consistency, which would make this fix more complete. Overall, this is a good improvement.

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 993d782 and 0623fb0.

📒 Files selected for processing (1)
  • components/button/style/variant.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/style/variant.ts
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/**/*.{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/style/variant.ts
**/*.{ts,tsx,md}

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

Use 2-space indentation

Files:

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

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

Maintain cross-browser compatibility

Files:

  • 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/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 (11)
📓 Common learnings
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
📚 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/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 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: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/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} : Component-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)

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
📚 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/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/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 : Generate styles with functions named `gen[ComponentName]Style`

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
⏰ 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: build preview
  • GitHub Check: lint
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: build
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-node
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: size
  • GitHub Check: build
🔇 Additional comments (2)
components/button/style/variant.ts (2)

234-238: 验证所有新token是否已正确声明。

需要确认defaultColordefaultHoverColordefaultHoverBgdefaultActiveBg这些token已在ButtonToken类型定义中声明,且遵循组件token命名规范。

运行以下脚本验证token声明:

#!/bin/bash
# 描述: 验证新增的Button token是否已声明

# 查找ButtonToken接口定义
echo "=== ButtonToken接口定义 ==="
rg -nP --type=ts 'interface ButtonToken' -A 50

# 搜索所有defaultColor相关token的声明
echo -e "\n=== defaultColor系列token ==="
rg -nP --type=ts '\b(defaultColor|defaultHoverColor|defaultBg|defaultHoverBg|defaultActiveBg)\s*[?:]' -B 2 -A 1

# 查找token定义文件
echo -e "\n=== Button token定义文件 ==="
fd -e ts -e tsx token components/button/

39-39: 所有 token 定义均已正确配置,修改逻辑无误。

验证结果:

  • defaultBgdefaultColordefaultHoverColordefaultHoverBgdefaultActiveBg 均已在 ComponentToken 接口(token.ts 第 13-239 行)中定义
  • 所有 token 在 prepareComponentToken 函数(token.ts 第 282-359 行)中获得默认值

Line 39 的修改允许用户通过 token.defaultBg 自定义背景色,使用了正确的 nullish coalescing 回退到 token.colorBgContainer

建议:Lines 234-237 应与 Line 39 保持一致,为 token.defaultColortoken.defaultHoverColortoken.defaultHoverBgtoken.defaultActiveBg 各自添加相应的回退值,确保防御性编程的统一性。

@pkg-pr-new
Copy link
Copy Markdown
pkg-pr-new bot commented Dec 16, 2025

@codecov
Copy link
Copy Markdown
codecov bot commented Dec 16, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #56238   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          807       807           
  Lines        14923     14924    +1     
  Branches      3931      3932    +1     
=========================================
+ Hits         14923     14924    +1     

☔ 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.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: ug <62086147+ug-hero@users.noreply.github.com>
@codecov
Copy link
Copy Markdown
codecov bot commented Dec 16, 2025

Bundle Report

Changes will increase total bundle size by 272 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.86MB 272 bytes (0.01%) ⬆️

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 136 bytes 2.12MB 0.01%
antd.min.js 136 bytes 1.74MB 0.01%

@ug-hero ug-hero changed the title fix(Button): defaultBg, defaultColor and defaultColor token does not work fix(Button): defaultBg, defaultColor, defaultColor and defaultActiveColor token does not work Dec 17, 2025
@ug-hero ug-hero changed the title fix(Button): defaultBg, defaultColor, defaultColor and defaultActiveColor token does not work fix(Button): defaultBg, defaultColor, defaultHoverColor and defaultActiveColor token does not work Dec 17, 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/component-token.tsx (1)

106-121: 这个演示正确展示了 Button 组件令牌的实现。

经验证,defaultBgdefaultColordefaultHoverColordefaultActiveColor 令牌已在 components/button/style/token.tscomponents/button/style/variant.ts 中正确实现。

关于颜色对比度:虽然使用的颜色组合(黑色背景 #000 上的红色 #f00 和绿色 #0f0)在 WCAG 2.1 AA 标准下对比度不足,但这些是演示代码中的极端颜色值,用于明确展示令牌效果如何影响按钮样式。这对于证明 PR 修复是否成功是可以接受的。

建议改进演示以展示所有令牌效果:添加注释或说明文字提示用户悬停/点击按钮查看 defaultHoverColordefaultActiveColor 的效果,因为当前演示仅展示静态状态。

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee60384 and 3eede09.

📒 Files selected for processing (1)
  • components/button/demo/component-token.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{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/component-token.tsx
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/component-token.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/component-token.tsx
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/component-token.tsx
**/*.{ts,tsx,md}

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

Use 2-space indentation

Files:

  • components/button/demo/component-token.tsx
**/*.{ts,tsx,css}

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

Maintain cross-browser compatibility

Files:

  • components/button/demo/component-token.tsx
**/*.{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/component-token.tsx
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/component-token.tsx
🧠 Learnings (11)
📓 Common learnings
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
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)
📚 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/component-token.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instru
992E
ctions.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/component-token.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-level Token naming should follow: Component + property name (e.g., buttonPrimaryColor)

Applied to files:

  • components/button/demo/component-token.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} : Components should use global Tokens and component-level Tokens for styling

Applied to files:

  • components/button/demo/component-token.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/component-token.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/**/demo/*.tsx : Demo code import order: React → dependencies → antd components → custom components → types → styles

Applied to files:

  • components/button/demo/component-token.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 : Support both light and dark themes

Applied to files:

  • components/button/demo/component-token.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/component-token.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/**/demo/*.tsx : Arrange demos from simple to complex

Applied to files:

  • components/button/demo/component-token.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} : Ensure sufficient color contrast and do not rely on color alone to convey information

Applied to files:

  • components/button/demo/component-token.tsx
🧬 Code graph analysis (1)
components/button/demo/component-token.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: build preview
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test-node
  • GitHub Check: lint
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: build
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: build
  • GitHub Check: size

@dosubot dosubot bot mentioned this pull request Jan 14, 2026
@QDyanbing
Copy link
Copy Markdown
Contributor

同步下master代码

@thinkasany
Copy link
Copy Markdown
Member

同步下master代码

done. 辛苦再 review 一下

@QDyanbing
Copy link
Copy Markdown
Contributor

应该是问题不大的;之前还以为这pr早就被合了呢;

thinkasany
thinkasany previously approved these changes Jan 28, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 28, 2026
[varName('bg-color-active')]: varRef('bg-color'),
[varName('bg-color-disabled')]: token.colorBgContainerDisabled,
[varName('bg-color-container')]: token.colorBgContainer,
[varName('bg-color-container')]: token.defaultBg ?? token.colorBgContainer,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

不能用条件式,v6 只会生成一套 CSS,然后通过 cssVar 来填充。这里编译成 css 后只会保留 token.defaultBg

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ug-hero ?? token.colorBgContainer看起来去掉就行token.ts里应该处理了默认值

@QDyanbing
Copy link
Copy Markdown
Contributor

可以帮顺便处理下debug demo把 debug-color-variant.tsx里的这两个干掉
image
新的debug demo就放你现在这个地方compinent-token这个里面和你这个容一起 大概

<ConfigProvider
  theme={{
    components: {
      Button: {
        defaultBg: "red",
        defaultColor: "blue",
        defaultHoverColor: "green",
        defaultActiveColor: "yellow",

        textTextColor: "purple",
        textTextHoverColor: "orange",
        textTextActiveColor: "pink",
        textHoverBg: "brown",
      },
    },
  }}
>
  <Flex gap="small" align="start">
    <Button>Default Button</Button>
    <Button type="dashed">Dashed Button</Button>
    <Button type="text">Text Button</Button>
  </Flex>
</ConfigProvider>

这样就行

fix
< 7292 div class="pr-1 flex-shrink-0" style="width: 16px;">
@thinkasany
Copy link
Copy Markdown
Member
thinkasany commented Jan 29, 2026

可以帮顺便处理下debug demo把 debug-color-variant.tsx里的这两个干掉 image 新的debug demo就放你现在这个地方compinent-token这个里面和你这个容一起 大概

<ConfigProvider
  theme={{
    components: {
      Button: {
        defaultBg: "red",
        defaultColor: "blue",
        defaultHoverColor: "green",
        defaultActiveColor: "yellow",

        textTextColor: "purple",
        textTextHoverColor: "orange",
        textTextActiveColor: "pink",
        textHoverBg: "brown",
      },
    },
  }}
>
  <Flex gap="small" align="start">
    <Button>Default Button</Button>
    <Button type="dashed">Dashed Button</Button>
    <Button type="text">Text Button</Button>
  </Flex>
</ConfigProvider>

这样就行

@QDyanbing 你那边可以建议代码么,可以直接这么建议,然后我合并进去。也可以多选几行
image
image

thinkasany and others added 2 commits January 29, 2026 22:50
Co-authored-by:  高艳兵 <66234749+QDyanbing@users.noreply.github.com>
Signed-off-by: thinkasany <480968828@qq.com>
@thinkasany thinkasany requested a review from zombieJ January 30, 2026 02:40
[varName('bg-color-active')]: varRef('bg-color'),
[varName('bg-color-disabled')]: token.colorBgContainerDisabled,
[varName('bg-color-container')]: token.colorBgContainer,
[varName('bg-color-container')]: token.defaultBg,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

预设变量应该用 colorBgContainer,在 color 为 default 的时候才切换到 defaultBg 上去

thinkasany and others added 2 commits January 30, 2026 14:04
Co-authored-by:  高艳兵 <66234749+QDyanbing@users.noreply.github.com>
Signed-off-by: thinkasany <480968828@qq.com>
Co-authored-by:  高艳兵 <66234749+QDyanbing@users.noreply.github.com>
Signed-off-by: thinkasany <480968828@qq.com>
@zombieJ zombieJ merged commit 7dd385b into ant-design:master Jan 30, 2026
36 of 38 checks passed
@QDyanbing QDyanbing mentioned this pull request Jan 30, 2026
17 tasks
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.

ConfigProvider - defaultBg, defaultColor and defaultColor for Button not working in v6.1.1

5 participants

0