Skip to content

fix: Searched text is black in dark mode in select component - #55914

Merged
afc163 merged 3 commits into
ant-design:masterfrom
divyeshagrawal:fix-select-title
Nov 26, 2025
Merged

afc163 merged 3 commits into
ant-design:masterfrom
divyeshagrawal:fix-select-title

Conversation

@divyeshagrawal

@divyeshagrawal divyeshagrawal commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

💡 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 Fix color of searched text is black in dark mode
🇨🇳 Chinese 在深色模式下修复搜索文本的颜色为黑色

@bolt-new-by-stackblitz

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

Preview is ready

@github-actions

github-actions Bot commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

👁 Visual Regression Report for PR #55914 Failed ❌

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

Expected (Branch master) Actual (Current PR) Diff
select-debug-flip-shift.default.png select-debug-flip-shift.default.png select-debug-flip-shift.default.png select-debug-flip-shift.default.png

Important

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

  • Visual diff is acceptable

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @divyeshagrawal, 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!

This pull request implements a crucial style fix for the Select component, specifically targeting its behavior in dark mode. The change ensures that placeholder text is clearly visible by setting its color to white with a slight transparency, thereby enhancing the user experience and resolving a reported accessibility issue.

Highlights

  • Bug Fix: Resolved an issue where the Select component's placeholder text was not appropriately visible in dark mode.
  • Style Improvement: Adjusted the styling to ensure the Select component's placeholder color is white with 50% opacity when in dark mode, improving readability.
  • Issue Resolution: This pull request addresses and closes issue Select search text color is black in dark mode (v6.0) #55824, which reported the dark mode placeholder visibility problem.
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. ↩

@coderabbitai

coderabbitai Bot commented Nov 26, 2025 •

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Summary by CodeRabbit

样式

  • 改进了输入框文本颜色的继承方式
  • 调整了搜索取消按钮的默认外观显示

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

概述

修改了 components/select/style/select-input.ts 文件中的样式声明,添加了 color: 'inherit' 属性使输入框文本颜色继承父元素样式,以解决暗色模式下搜索文本颜色显示为黑色的问题。同时添加了 appearance: 'none' 属性隐藏 WebKit 搜索取消按钮的默认外观。

变更内容

内聚体 / 文件 变更摘要
选择框输入样式调整
components/select/style/select-input.ts
为基础输入样式添加 color: 'inherit' 属性;为 ::-webkit-search-cancel-button 伪元素添加 appearance: 'none' 属性

代码审查工作量评估

🎯 1 (简单) | ⏱️ ~5 分钟

需要关注的方面:

  • 验证 color: 'inherit' 在所有暗色和亮色主题场景下的表现
  • 确认 appearance: 'none' 对不同浏览器(特别是 Safari)中搜索按钮显示的影响
  • 测试输入框在嵌套组件中颜色继承的正确性

诗篇

🐰 暗夜里的文字终于闪闪发光,
继承父亲的颜色,不再迷茫,
取消按钮也换了新装,
简洁优雅,让用户心欢畅。

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed 描述与变更集相关,明确指出修复的是深色模式下搜索文本颜色问题,并链接了相关Issue。
Linked Issues check ✅ Passed PR通过添加color: 'inherit'实现搜索输入文本颜色继承,使文本在深色模式下显示为白色,满足Issue #55824的核心需求。
Out of Scope Changes check ✅ Passed PR除了修复搜索文本颜色问题外,还添加了appearance: 'none'以隐藏webkit取消按钮,这是相关的样式改进,未发现明显的范围外变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed PR标题与变更内容基本相关,但存在轻微不准确之处。标题提及'搜索文本'和'深色模式',这与实际变更(继承颜色、取消按钮样式)部分相关,但标题描述的是解决的用户问题而非代码层面的具体改变。
✨ 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 gemini-code-assist Bot left a comment

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.

Code Review

This pull request aims to fix the placeholder color in the Select component for dark mode by increasing its opacity. The approach taken in components/select/style/index.ts has a critical flaw: it attempts to wrap an existing rgba color string within another rgba function, which results in invalid CSS. I've provided a comment with a suggested fix that uses an appropriate theme token (token.colorTextTertiary) to achieve the desired effect in a safe and theme-consistent way. This will resolve the visibility issue for the placeholder in both light and dark modes.

Comment thread components/select/style/index.ts Resolved
@pkg-pr-new

pkg-pr-new Bot commented Nov 26, 2025 •

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 26, 2025 •

Copy link
Copy Markdown

Bundle Report

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

Detailed changes
Bundle name Size Change
antd.min-array-push 12.14MB 56 bytes (0.0%) ⬆️

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.js 28 bytes 6.38MB 0.0%
antd.js 28 bytes 5.76MB 0.0%

@coderabbitai coderabbitai Bot left a comment

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.

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 0f86901 and 5a26866.

📒 Files selected for processing (1)
  • components/select/style/index.ts (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/select/style/index.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/select/style/index.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/select/style/index.ts
**/*.{ts,tsx,md}

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

Use 2-space indentation

Files:

  • components/select/style/index.ts
**/*.{ts,tsx,css}

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

Maintain cross-browser compatibility

Files:

  • components/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.ts
🧠 Learnings (10)
📚 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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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/select/style/index.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: test lib/es module (es, 1/2)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: build
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-node
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: lint
  • GitHub Check: build
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: size

Comment thread components/select/style/index.ts Outdated
inputPaddingHorizontalBase: token.calc(token.paddingSM).sub(token.lineWidth).equal(),
multipleSelectItemHeight: token.multipleItemHeight,
selectHeight: token.controlHeight,
colorTextPlaceholder: `rgba(${token.colorTextPlaceholder}, 0.5)`,

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Script executed:

#!/bin/bash
# First, let's examine the file and the context around line 155
echo "=== Content of components/select/style/index.ts around line 155 ==="
head -n 170 components/select/style/index.ts | tail -n 30

echo -e "\n=== Looking for SelectToken interface definition ==="
rg -n "interface SelectToken|type SelectToken" -A 20 components/select/style/index.ts

echo -e "\n=== Checking for colorTextPlaceholder definition ==="
rg -n "colorTextPlaceholder" -B 2 -A 2

Repository: ant-design/ant-design


<shell_result>
Repository: ant-design/ant-design
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository ant-design/ant-design: Clone operation failed
</shell_result>


Ant Design v5 token system colorTextPlaceholder rgba opacity


<web_search_result>
Short answer: colorTextPlaceholder is an Ant Design v5 AliasToken you can set to any CSS color (including rgba) — it maps from the old @input-placeholder-color and controls input/placeholder appearance. To change placeholder opacity use an rgba() (or hsla()/8-digit hex) value when you set the token.

Example (ConfigProvider):
<ConfigProvider theme={{ token: { colorTextPlaceholder: 'rgba(0,0,0,0.38)' } }}>
...

Sources:

  • Ant Design theme / customize-theme (tokens via ConfigProvider). [1]
  • Mapping of old Less variable @input-placeholder-color → colorTextPlaceholder. [2]
  • Example usage of overriding tokens (ConfigProvider examples). [3]

References:
[1] https://3x.ant.design/docs/react/customize-theme
[2] https://attach.w3cschool.cn/docsreactintroduce/ant-design-react-from-the-less-variable-to-the-design-token.html
[3] https://blog.csdn.net/qq_60178319/article/details/133684416
</web_search_result>


@ant-design/cssinjs rgba color utility functions


<web_search_result>
Short answer: @ant-design/cssinjs itself does not expose a dedicated "rgba" helper; Ant Design uses the @ant-design/fast-color package for color parsing/manipulation (including producing rgba/rgb strings and adjusting alpha). You can use FastColor to parse colors and output rgba (or modify alpha) in your cssinjs styles. [1][2]

Example (JS/TS):

  • install: npm i @ant-design/fast-color
  • usage:
    const { FastColor } = require('@ant-design/fast-color');
    const c = new FastColor('#1890ff');
    c.toRgbString(); // "rgb(24,144,255)"
    c.setAlpha(0.5); // (or new FastColor({ ... , a: 0.5 }))
    c.toRgbString(true); // or c.toRgbString() with alpha support depending on version → "rgba(24,144,255,0.5)"
    // use result in css-in-js style value

References:

  • @ant-design/cssinjs package (mentions color utilities and related packages). [1]
  • @ant-design/fast-color (API, parse/outputs like toRgbString/toHex and alpha support). [2]

Sources:
[1] @ant-design/cssinjs — npm package/readme.
[2] @ant-design/fast-color — npm package/readme.
</web_search_result>


Ant Design Select component dark mode placeholder color


<web_search_result>
Short answer — two options:

  1. Quick CSS override (works across versions)
  • Target the placeholder element and set color + opacity (Ant uses opacity: 0.4 by default):
    .ant-select-selection-placeholder { color: #cfcfcf; opacity: 1; }
  • If you use scoped CSS / CSS-in-JS, you may need a deep selector (e.g. ::v-deep or :global) to penetrate Ant’s styles. [1]
  1. Proper theming in antd v5 (preferred)
  • Use ConfigProvider theme tokens. The placeholder color is governed by colorTextPlaceholder (alias/global token) and can also be set per-component under theme.components.Select. Example:
    <ConfigProvider theme={{ token: { colorTextPlaceholder: '#cfcfcf' }, components: { Select: { /* component tokens */ } } }}>
    ...
  • This respects darkAlgorithm / dark theme semantics. [2][3]

References:

  • How to override Select placeholder (class & default opacity). [1]
  • AntD token mapping (colorTextPlaceholder) and ConfigProvider theming (v5). [2][3]
    </web_search_result>

Ant Design token format colorTextPlaceholder actual color value hex rgb


<web_search_result>

If you want the exact value used in your build, tell me your antd version (e.g. 4.x or 5.x) and I’ll fetch the token source.

Citations:


Ant Design cssinjs fast-color how to apply alpha opacity to token


<web_search_result>
Short answer — parse the token with @ant-design/fast-color, then produce an rgba() string with the alpha you want (cssinjs will accept that string). Example:

  • Install: npm i @ant-design/fast-color

  • Parse token and build rgba with alpha:

    import { FastColor } from '@ant-design/fast-color';
    import { useStyleRegister } from '@ant-design/cssinjs';

    // inside style function where token.colorPrimary exists
    const fc = new FastColor(token.colorPrimary); // parse token
    const { r, g, b } = fc.toRgb(); // get rgb
    const myAlpha = 0.5; // desired alpha 0..1
    const colorWithAlpha = rgba(${r}, ${g}, ${b}, ${myAlpha});

    useStyleRegister('MyComp', () => ({
    '.my': { color: colorWithAlpha },
    }));

Notes:

  • FastColor accepts hex8 / rgba / hsl inputs and returns toRgb() with r,g,b,a. Use those values to format rgba(...) with any alpha. (npmjs.com)

If you want the output as a hex8 string instead, convert r/g/b/a to hex with a tiny helper (or use a color util like tinycolor).

Citations:


Ant Design Select component token colorTextPlaceholder implementation


<web_search_result>
Short answer: Ant Design's Select placeholder styling moved away from the alias token colorTextPlaceholder — the Select visuals (icons/placeholder) now use the quaternary text token (colorTextQuaternary) in recent changes. You can override it either by CSS (target .ant-select-selection__placeholder / .ant-select-selection-placeholder) or by overriding theme tokens for Select via ConfigProvider.theme (set the alias/component token such as colorTextQuaternary or the Select component token). [1][2][3]

Sources

  • Figma / design update noting Select arrow/placeholder color change (colorTextPlaceholder → colorTextQuaternary). [1]
  • Ant Design Select docs (component structure / placeholder element/class). [3]
  • Community: how to style Select placeholder with .ant-select-selection__placeholder / .ant-select-selection-placeholder. [2]
  • Ant Design theming / ConfigProvider token override docs (use theme.token and theme.components to override tokens). [4][5]

References
[1] Ant Design System for Figma — update note (change arrow color in Select from colorTextPlaceholder to colorTextQuaternary).
[2] StackOverflow — styling Select placeholder (.ant-select-selection__placeholder).
[3] Ant Design Select component docs.
[4] Ant Design theming / ConfigProvider token override examples.
[5] Ant Design design-token architecture / how component tokens are derived.
</web_search_result>


Ant Design dark mode colorTextPlaceholder token value dark algorithm


<web_search_result>
Short answer: colorTextPlaceholder is an alias that maps to colorTextQuaternary — in Ant Design’s theme generation the token colorTextPlaceholder = mergedToken.colorTextQuaternary (so under theme.darkAlgorithm its value is whatever the darkAlgorithm derives for colorTextQuaternary). [1]

Sources:

  • Ant Design token mapping in the runtime theme bundle (shows colorTextPlaceholder -> mergedToken.colorTextQuaternary). [1]
  • Ant Design docs on dark mode / theme algorithms (describes the darkAlgorithm deriving map/alias tokens). [2]
    </web_search_result>

Ant Design Select placeholder dark mode issue white color


<web_search_result>
Short answer: override the Select placeholder element (.ant-select-selection-placeholder) and reset its default opacity (0.4). Example CSS for dark mode:

.ant-select .ant-select-selection-placeholder {
color: #bfbfbf !important; /* desired light-gray on dark bg */
opacity: 1 !important;
}

/* If using the dark theme wrapper (e.g. ConfigProvider dark / .ant-dark) scope it: */
.ant-dark .ant-select .ant-select-selection-placeholder {
color: #bfbfbf !important;
opacity: 1 !important;
}

Notes: the placeholder element is .ant-select-selection-placeholder (AntD v4+), and AntD applies opacity:0.4 by default so you must reset it. Use a scoped selector or :global / ::v-deep depending on your CSS setup to avoid style encapsulation issues. [1][2][3]

Sources:
[1] Ant Design — Dark Mode docs.
[2] Ant Design — Customize theme / style guidance.
[3] StackOverflow — styling Select placeholder (.ant-select-selection-placeholder) and default opacity.
</web_search_result>


Based on my verification through web search, I can now provide the final rewritten review comment:


Invalid CSS syntax—this will break placeholder styling in both light and dark modes.

The code produces invalid CSS. token.colorTextPlaceholder is already a complete color value (e.g., rgba(0, 0, 0, 0.35) in light mode), so wrapping it as rgba(${token.colorTextPlaceholder}, 0.5) generates "rgba(rgba(0, 0, 0, 0.35), 0.5)" or "rgba(#ffffff, 0.5)", both invalid. Browsers will ignore this value entirely, and the placeholder will not display.

Issues:

  1. Critical: Syntax error—nested rgba/hex in rgba() is not valid CSS. Use @ant-design/fast-color to properly parse the token and construct a valid rgba string if opacity adjustment is needed:

    import { FastColor } from '@ant-design/fast-color';
    const fc = new FastColor(token.colorTextPlaceholder);
    const { r, g, b } = fc.toRgb();
    colorTextPlaceholder: `rgba(${r}, ${g}, ${b}, 0.5)`
  2. Major: Hardcoded opacity—the 0.5 value violates the token-based design approach. Use design tokens instead (e.g., colorTextTertiary or colorTextQuaternary if a less-visible placeholder is needed).

  3. Major: Misses the real issue—colorTextPlaceholder is an alias for colorTextQuaternary and already receives the correct theme-aware color via darkAlgorithm. The problem is likely the default opacity of 0.4 applied to placeholder elements. Fix the token value itself or adjust opacity separately, rather than wrapping the token.

🤖 Prompt for AI Agents
In components/select/style/index.ts around line 155, the current line wraps
token.colorTextPlaceholder inside rgba(...) which produces invalid CSS (e.g.
rgba(rgba(...), 0.5) or rgba(#fff, 0.5)); replace this by either using the
existing theme token (e.g., colorTextQuaternary or colorTextPlaceholder
directly) instead of wrapping it, or if you must change opacity, parse
token.colorTextPlaceholder with @ant-design/fast-color to extract r,g,b and
build a valid rgba(r, g, b, alpha) string and avoid hardcoding
opacity—preferably update the design token to expose the desired opacity rather
than manipulating the color string in place.

@codecov

codecov Bot commented Nov 26, 2025 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #55914   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          803       803           
  Lines        14812     14812           
  Branches      3913      3913           
=========================================
  Hits         14812     14812           

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

@Wxh16144

Copy link
Copy Markdown
Member

I think you misunderstood the issue feedback. It's not about fixing the placeholder color issue, but rather that the input box can input any text for search, and the entered text turns black. In dark mode, it's not visible what has been entered. This problem should be addressed.

@divyeshagrawal

Copy link
Copy Markdown
Contributor Author

I think you misunderstood the issue feedback. It's not about fixing the placeholder color issue, but rather that the input box can input any text for search, and the entered text turns black. In dark mode, it's not visible what has been entered. This problem should be addressed.

Oh! Yeah I completely misunderstood. Thanks for clarification! will work on the fix and update this PR

@afc163

afc163 commented Nov 26, 2025

Copy link
Copy Markdown
Member

#55824 (comment)

Comment thread components/select/style/index.ts Outdated
inputPaddingHorizontalBase: token.calc(token.paddingSM).sub(token.lineWidth).equal(),
multipleSelectItemHeight: token.multipleItemHeight,
selectHeight: token.controlHeight,
colorTextPlaceholder: `rgba(${token.colorTextPlaceholder}, 0.5)`,

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.

直接给 input 加一个 color: inherit; 样式吧~

@divyeshagrawal divyeshagrawal changed the title fix: Make select placeholder color white in dark mode fix: Searched text is black in dark mode in select component Nov 26, 2025
@divyeshagrawal

Copy link
Copy Markdown
Contributor Author

/gemini review

@divyeshagrawal

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 26, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

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.

Code Review

This pull request addresses an issue where searched text within the Select component remains black in dark mode, making it unreadable. The fix correctly applies color: 'inherit' to the select input, resolving the problem for standard select components. My review includes one comment pointing out that this fix may not apply to the customize variant of the Select component due to the CSS selector used. I've suggested ensuring the fix is applied universally to all select variants for consistency.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/select/style/select-input.ts (1)

254-257: 考虑移除可能冗余的 appearance: 'none'。

在 ::-webkit-search-cancel-button 选择器中,第 255 行已经设置了 display: 'none',这会完全隐藏该元素。在此情况下,第 256 行的 appearance: 'none' 可能是多余的,因为元素已经不可见了。

如果没有特殊原因(例如,未来可能会改变 display 属性),可以考虑移除第 256 行以保持代码简洁。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5a26866 and 02d5af6.

📒 Files selected for processing (1)
  • components/select/style/select-input.ts (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/select/style/select-input.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/select/style/select-input.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/select/style/select-input.ts
**/*.{ts,tsx,md}

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

Use 2-space indentation

Files:

  • components/select/style/select-input.ts
**/*.{ts,tsx,css}

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

Maintain cross-browser compatibility

Files:

  • components/select/style/select-input.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/select/style/select-input.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/select/style/select-input.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/select/style/select-input.ts
🧠 Learnings (4)
📚 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/select/style/select-input.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/select/style/select-input.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/select/style/select-input.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/select/style/select-input.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). (17)
  • GitHub Check: refuse
  • GitHub Check: check-changelog
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test lib/es module (lib, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: build
  • GitHub Check: test-node
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: lint
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: build preview
  • GitHub Check: size
  • GitHub Check: build
🔇 Additional comments (2)
components/select/style/select-input.ts (2)

252-252: 注意:PR 标题与实际修复内容不一致。

PR 标题提到"使选择框占位符颜色在深色模式下变为白色",但根据 Wxh16144 的评论和实际代码更改,真正的问题是输入的搜索文本在深色模式下显示为黑色,而不是占位符颜色的问题。

此修改(color: 'inherit')正确地修复了输入文本颜色的问题,因为:

  • 占位符是独立元素(第 155 行),有自己的颜色设置 token.colorTextPlaceholder
  • 此修改影响的是 ${componentCls}-input 元素,即用户输入时的文本颜色

建议更新 PR 标题和描述,以准确反映修复的是"搜索输入文本颜色"而非"占位符颜色"。


252-252: Based on my verification through web search, I can now provide you with the rewritten review comment:


Verify that token.colorText correctly resolves to white/light color in dark mode.

The addition of color: 'inherit' at line 252 is the correct approach—it makes the input text inherit from the parent element's computed color (via the --select-color CSS variable, which is set to token.colorText). Since Ant Design's darkAlgorithm properly derives token.colorText as white/light in dark mode, this should resolve the black text issue you identified in the PR comments.

The change at line 256 (appearance: 'none' on the webkit-search-cancel-button) is not redundant; it complements the display: 'none' on line 255. Both properties are needed: appearance: 'none' removes browser default styling, while display: 'none' removes the element from layout flow. This is the standard pattern for reliably hiding WebKit pseudo-elements across browsers.

Actions:

  • Confirm this renders correctly in both light and dark themes
  • Test that placeholder text (line 155) and typed search text both appear with proper contrast

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Nov 26, 2025
@afc163
afc163 merged commit 2311d31 into ant-design:master Nov 26, 2025
45 checks passed
@PeachScript PeachScript mentioned this pull request Dec 2, 2025
1 of 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.

Select search text color is black in dark mode (v6.0)

4 participants