diff --git a/components/select/__tests__/demo-extend.test.ts b/components/select/__tests__/demo-extend.test.ts
index 770b2233ca..13f655dd72 100644
--- a/components/select/__tests__/demo-extend.test.ts
+++ b/components/select/__tests__/demo-extend.test.ts
@@ -1,3 +1,3 @@
import { extendTest } from '../../../tests/shared/demoTest';
-extendTest('select', { skip: ['render-panel.tsx', 'big-data.tsx'] });
+extendTest('select', { skip: ['render-panel.tsx', 'big-data.tsx', 'component-token.tsx'] });
diff --git a/components/select/__tests__/demo.test.tsx b/components/select/__tests__/demo.test.tsx
index ce4fb72cc7..ab5b0dd5b3 100644
--- a/components/select/__tests__/demo.test.tsx
+++ b/components/select/__tests__/demo.test.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import demoTest, { rootPropsTest } from '../../../tests/shared/demoTest';
demoTest('select', {
- skip: ['render-panel.tsx'],
+ skip: ['render-panel.tsx', 'component-token.tsx'],
testRootProps: false,
});
diff --git a/components/select/demo/component-token.md b/components/select/demo/component-token.md
new file mode 100644
index 0000000000..83366668fe
--- /dev/null
+++ b/components/select/demo/component-token.md
@@ -0,0 +1,7 @@
+## zh-CN
+
+组件 Token
+
+## en-US
+
+Component Token
diff --git a/components/select/demo/component-token.tsx b/components/select/demo/component-token.tsx
new file mode 100644
index 0000000000..f3d398fac6
--- /dev/null
+++ b/components/select/demo/component-token.tsx
@@ -0,0 +1,53 @@
+import React from 'react';
+import { ConfigProvider, Select, Space } from 'antd';
+import type { SelectProps } from 'antd';
+
+const options: SelectProps['options'] = [];
+
+for (let i = 10; i < 36; i++) {
+ options.push({
+ label: i.toString(36) + i,
+ value: i.toString(36) + i,
+ });
+}
+
+const handleChange = (value: string[]) => {
+ console.log(`selected ${value}`);
+};
+
+const App: React.FC = () => (
+
+
+
+
+
+
+);
+
+export default App;
diff --git a/components/select/index.en-US.md b/components/select/index.en-US.md
index c6f940e1eb..8d0c68a111 100644
--- a/components/select/index.en-US.md
+++ b/components/select/index.en-US.md
@@ -45,6 +45,7 @@ Select component to select value from options.
\_InternalPanelDoNotUseOrYouWillBeFired
Options label Centered
Flip + Shift
+Component Token
## API
diff --git a/components/select/index.zh-CN.md b/components/select/index.zh-CN.md
index 468ca665b1..1850ac83b6 100644
--- a/components/select/index.zh-CN.md
+++ b/components/select/index.zh-CN.md
@@ -46,6 +46,7 @@ demo:
\_InternalPanelDoNotUseOrYouWillBeFired
选项文本居中
翻转+偏移
+组件 Token
## API
diff --git a/components/select/style/dropdown.tsx b/components/select/style/dropdown.tsx
index f690e3033c..a0ab4410f5 100644
--- a/components/select/style/dropdown.tsx
+++ b/components/select/style/dropdown.tsx
@@ -12,17 +12,17 @@ import {
import type { GenerateStyle } from '../../theme/internal';
const genItemStyle: GenerateStyle = (token) => {
- const { controlPaddingHorizontal, controlHeight, fontSize, lineHeight } = token;
+ const { optionHeight, optionFontSize, optionLineHeight, optionPadding } = token;
return {
position: 'relative',
display: 'block',
- minHeight: controlHeight,
- padding: `${(controlHeight - fontSize * lineHeight) / 2}px ${controlPaddingHorizontal}px`,
+ minHeight: optionHeight,
+ padding: optionPadding,
color: token.colorText,
fontWeight: 'normal',
- fontSize,
- lineHeight,
+ fontSize: optionFontSize,
+ lineHeight: optionLineHeight,
boxSizing: 'border-box',
};
};
@@ -120,13 +120,13 @@ const genSingleStyle: GenerateStyle = (token) => {
},
[`&-active:not(${selectItemCls}-option-disabled)`]: {
- backgroundColor: token.controlItemBgHover,
+ backgroundColor: token.optionActiveBg,
},
[`&-selected:not(${selectItemCls}-option-disabled)`]: {
- color: token.colorText,
- fontWeight: token.fontWeightStrong,
- backgroundColor: token.controlItemBgActive,
+ color: token.optionSelectedColor,
+ fontWeight: token.optionSelectedFontWeight,
+ backgroundColor: token.optionSelectedBg,
[`${selectItemCls}-option-state`]: {
color: token.colorPrimary,
diff --git a/components/select/style/index.tsx b/components/select/style/index.tsx
index 1c7b683fa0..e00e8f0c14 100644
--- a/components/select/style/index.tsx
+++ b/components/select/style/index.tsx
@@ -1,4 +1,5 @@
import type { CSSObject } from '@ant-design/cssinjs';
+import type { CSSProperties } from 'react';
import { resetComponent, resetIcon, textEllipsis } from '../../style';
import { genCompactItemStyle } from '../../style/compact-item';
import type { FullToken, GenerateStyle } from '../../theme/internal';
@@ -13,20 +14,111 @@ export interface ComponentToken {
* @descEN z-index of dropdown
*/
zIndexPopup: number;
+ /**
+ * @desc 选项选中时文本颜色
+ * @descEN Text color when option is selected
+ */
+ optionSelectedColor: string;
+ /**
+ * @desc 选项选中时文本字重
+ * @descEN Font weight when option is selected
+ */
+ optionSelectedFontWeight: CSSProperties['fontWeight'];
+ /**
+ * @desc 选项选中时背景色
+ * @descEN Background color when option is selected
+ */
+ optionSelectedBg: string;
+ /**
+ * @desc 选项激活态时背景色
+ * @descEN Background color when option is active
+ */
+ optionActiveBg: string;
+ /**
+ * @desc 选项内间距
+ * @descEN Padding of option
+ */
+ optionPadding: CSSProperties['padding'];
+ /**
+ * @desc 选项字体大小
+ * @descEN Font size of option
+ */
+ optionFontSize: number;
+ /**
+ * @desc 选项行高
+ * @descEN Line height of option
+ */
+ optionLineHeight: CSSProperties['lineHeight'];
+ /**
+ * @desc 选项高度
+ * @descEN Height of option
+ */
+ optionHeight: number;
+ /**
+ * @desc 选框背景色
+ * @descEN Background color of selector
+ */
+ selectorBg: string;
+ /**
+ * @desc 清空按钮背景色
+ * @descEN Background color of clear button
+ */
+ clearBg: string;
+ /**
+ * @desc 单选大号回填项高度
+ * @descEN Height of single selected item with large size
+ */
+ singleItemHeightLG: number;
+ /**
+ * @desc 多选标签背景色
+ * @descEN Background color of multiple tag
+ */
+ multipleItemBg: string;
+ /**
+ * @desc 多选标签边框色
+ * @descEN Border color of multiple tag
+ */
+ multipleItemBorderColor: string;
+ /**
+ * @desc 多选标签高度
+ * @descEN Height of multiple tag
+ */
+ multipleItemHeight: number;
+ /**
+ * @desc 大号多选标签高度
+ * @descEN Height of multiple tag with large size
+ */
+ multipleItemHeightLG: number;
+ /**
+ * @desc 多选框禁用背景
+ * @descEN Background color of multiple selector when disabled
+ */
+ multipleSelectorBgDisabled: string;
+ /**
+ * @desc 多选标签禁用文本颜色
+ * @descEN Text color of multiple tag when disabled
+ */
+ multipleItemColorDisabled: string;
+ /**
+ * @desc 多选标签禁用边框色
+ * @descEN Border color of multiple tag when disabled
+ */
+ multipleItemBorderColorDisabled: string;
}
export interface SelectToken extends FullToken<'Select'> {
rootPrefixCls: string;
inputPaddingHorizontalBase: number;
+ multipleSelectItemHeight: number;
}
// ============================= Selector =============================
const genSelectorStyle: GenerateStyle = (token) => {
- const { componentCls } = token;
+ const { componentCls, selectorBg } = token;
return {
position: 'relative',
- backgroundColor: token.colorBgContainer,
+ backgroundColor: selectorBg,
border: `${token.lineWidth}px ${token.lineType} ${token.colorBorder}`,
transition: `all ${token.motionDurationMid} ${token.motionEaseInOut}`,
@@ -49,7 +141,7 @@ const genSelectorStyle: GenerateStyle = (token) => {
cursor: 'not-allowed',
[`${componentCls}-multiple&`]: {
- background: token.colorBgContainerDisabled,
+ background: token.multipleSelectorBgDisabled,
},
input: {
@@ -214,7 +306,7 @@ const genBaseStyle: GenerateStyle = (token) => {
lineHeight: 1,
textAlign: 'center',
textTransform: 'none',
- background: token.colorBgContainer,
+ background: token.clearBg,
cursor: 'pointer',
opacity: 0,
transition: `color ${token.motionDurationMid} ease, opacity ${token.motionDurationSlow} ease`,
@@ -333,11 +425,52 @@ export default genComponentStyleHook(
const selectToken: SelectToken = mergeToken(token, {
rootPrefixCls,
inputPaddingHorizontalBase: token.paddingSM - 1,
+ multipleSelectItemHeight: token.multipleItemHeight,
});
return [genSelectStyle(selectToken)];
},
- (token) => ({
- zIndexPopup: token.zIndexPopupBase + 50,
- }),
+ (token) => {
+ const {
+ fontSize,
+ lineHeight,
+ controlHeight,
+ controlPaddingHorizontal,
+ zIndexPopupBase,
+ colorText,
+ fontWeightStrong,
+ controlItemBgActive,
+ controlItemBgHover,
+ colorBgContainer,
+ colorFillSecondary,
+ controlHeightLG,
+ controlHeightSM,
+ colorBgContainerDisabled,
+ colorTextDisabled,
+ } = token;
+
+ return {
+ zIndexPopup: zIndexPopupBase + 50,
+ optionSelectedColor: colorText,
+ optionSelectedFontWeight: fontWeightStrong,
+ optionSelectedBg: controlItemBgActive,
+ optionActiveBg: controlItemBgHover,
+ optionPadding: `${
+ (controlHeight - fontSize * lineHeight) / 2
+ }px ${controlPaddingHorizontal}px`,
+ optionFontSize: fontSize,
+ optionLineHeight: lineHeight,
+ optionHeight: controlHeight,
+ selectorBg: colorBgContainer,
+ clearBg: colorBgContainer,
+ singleItemHeightLG: controlHeightLG,
+ multipleItemBg: colorFillSecondary,
+ multipleItemBorderColor: 'transparent',
+ multipleItemHeight: controlHeightSM,
+ multipleItemHeightLG: controlHeight,
+ multipleSelectorBgDisabled: colorBgContainerDisabled,
+ multipleItemColorDisabled: colorTextDisabled,
+ multipleItemBorderColorDisabled: 'transparent',
+ };
+ },
);
diff --git a/components/select/style/multiple.tsx b/components/select/style/multiple.tsx
index 157115dbad..c65691a115 100644
--- a/components/select/style/multiple.tsx
+++ b/components/select/style/multiple.tsx
@@ -20,7 +20,7 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
const selectOverflowPrefixCls = `${componentCls}-selection-overflow`;
- const selectItemHeight = token.controlHeightSM;
+ const selectItemHeight = token.multipleSelectItemHeight;
const [selectItemDist] = getSelectItemStyle(token);
const suffixCls = suffix ? `${componentCls}-${suffix}` : '';
@@ -63,7 +63,7 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
},
[`${componentCls}-disabled&`]: {
- background: token.colorBgContainerDisabled,
+ background: token.multipleSelectorBgDisabled,
cursor: 'not-allowed',
},
@@ -95,7 +95,8 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
marginTop: FIXED_ITEM_MARGIN,
marginBottom: FIXED_ITEM_MARGIN,
lineHeight: `${selectItemHeight - token.lineWidth * 2}px`,
- background: token.colorFillSecondary,
+ background: token.multipleItemBg,
+ border: `${token.lineWidth}px ${token.lineType} ${token.multipleItemBorderColor}`,
borderRadius: token.borderRadiusSM,
cursor: 'default',
transition: `font-size ${token.motionDurationSlow}, line-height ${token.motionDurationSlow}, height ${token.motionDurationSlow}`,
@@ -105,7 +106,8 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSObject {
paddingInlineEnd: token.paddingXS / 2,
[`${componentCls}-disabled&`]: {
- color: token.colorTextDisabled,
+ color: token.multipleItemColorDisabled,
+ borderColor: token.multipleItemBorderColorDisabled,
cursor: 'not-allowed',
},
@@ -196,7 +198,7 @@ const genMultipleStyle = (token: SelectToken): CSSInterpolation => {
const smallToken = mergeToken(token, {
controlHeight: token.controlHeightSM,
- controlHeightSM: token.controlHeightXS,
+ multipleSelectItemHeight: token.controlHeightXS,
borderRadius: token.borderRadiusSM,
borderRadiusSM: token.borderRadiusXS,
});
@@ -204,7 +206,7 @@ const genMultipleStyle = (token: SelectToken): CSSInterpolation => {
const largeToken = mergeToken(token, {
fontSize: token.fontSizeLG,
controlHeight: token.controlHeightLG,
- controlHeightSM: token.controlHeight,
+ multipleSelectItemHeight: token.multipleItemHeightLG,
borderRadius: token.borderRadiusLG,
borderRadiusSM: token.borderRadius,
});
diff --git a/components/select/style/single.tsx b/components/select/style/single.tsx
index 06c4fdf19b..654dc81bfd 100644
--- a/components/select/style/single.tsx
+++ b/components/select/style/single.tsx
@@ -182,7 +182,7 @@ export default function genSingleStyle(token: SelectToken): CSSInterpolation {
// Shared
genSizeStyle(
mergeToken(token, {
- controlHeight: token.controlHeightLG,
+ controlHeight: token.singleItemHeightLG,
fontSize: token.fontSizeLG,
borderRadius: token.borderRadiusLG,
}),
diff --git a/docs/react/migrate-less-variables.en-US.md b/docs/react/migrate-less-variables.en-US.md
index a832a5dd9b..2deb35b6de 100644
--- a/docs/react/migrate-less-variables.en-US.md
+++ b/docs/react/migrate-less-variables.en-US.md
@@ -528,7 +528,32 @@ export default App;
| `@segmented-label-hover-color` | `itemHoverColor` | - |
| `@segmented-selected-bg` | `itemSelectedBg` | - |
-
+### Select
+
+
+| Less variables | Component Token | Note |
+| --- | --- | --- |
+| `@select-border-color` | `colorBorder` | Global Token |
+| `@select-item-selected-color` | `optionSelectedColor` | - |
+| `@select-item-selected-font-weight` | `optionSelectedFontWeight` | - |
+| `@select-dropdown-bg` | `colorBgElevated` | Global Token |
+| `@select-item-selected-bg` | `optionSelectedBg` | - |
+| `@select-item-active-bg` | `optionActiveBg` | - |
+| `@select-dropdown-vertical-padding` | `optionPadding` | Control the whole padding |
+| `@select-dropdown-font-size` | `optionFontSize` | - |
+| `@select-dropdown-line-height` | `optionLineHeight` | - |
+| `@select-dropdown-height` | `optionHeight` | - |
+| `@select-background` | `selectorBg` | - |
+| `@select-clear-background` | `clearBg` | - |
+| `@select-selection-item-bg` | `multipleItemBg` | - |
+| `@select-selection-item-border-color` | `multipleItemBorderColor` | - |
+| `@select-single-item-height-lg` | `singleItemHeightLG` | - |
+| `@select-multiple-item-height` | `multipleItemHeight` | - |
+| `@select-multiple-item-height-lg` | `multipleItemHeightLG` | - |
+| `@select-multiple-item-spacing-half` | - | Deprecated |
+| `@select-multiple-disabled-background` | `multipleSelectorBgDisabled` | - |
+| `@select-multiple-item-disabled-color` | `multipleItemColorDisabled` | - |
+| `@select-multiple-item-disabled-border-color` | `multipleItemBorderColorDisabled` | - |
### Skeleton
diff --git a/docs/react/migrate-less-variables.zh-CN.md b/docs/react/migrate-less-variables.zh-CN.md
index b1eced5c3d..5e70890fe1 100644
--- a/docs/react/migrate-less-variables.zh-CN.md
+++ b/docs/react/migrate-less-variables.zh-CN.md
@@ -319,6 +319,8 @@ export default App;
| `@layout-trigger-background-light` | `lightTriggerBg` | - |
| `@layout-trigger-color-light` | `lightTriggerColor` | - |
+ssgit chekcout featuregit pucheckout featire'uregit pull
+
### List 列表
@@ -524,7 +526,32 @@ Mentions 提及
| `@segmented-label-hover-color` | `itemHoverColor` | - |
| `@segmented-selected-bg` | `itemSelectedBg` | - |
-
+### Select 选择器
+
+
+| Less 变量 | Component Token | 备注 |
+| --- | --- | --- |
+| `@select-border-color` | `colorBorder` | 全局 Token |
+| `@select-item-selected-color` | `optionSelectedColor` | - |
+| `@select-item-selected-font-weight` | `optionSelectedFontWeight` | - |
+| `@select-dropdown-bg` | `colorBgElevated` | 全局 Token |
+| `@select-item-selected-bg` | `optionSelectedBg` | - |
+| `@select-item-active-bg` | `optionActiveBg` | - |
+| `@select-dropdown-vertical-padding` | `optionPadding` | 控制整体内间距 |
+| `@select-dropdown-font-size` | `optionFontSize` | - |
+| `@select-dropdown-line-height` | `optionLineHeight` | - |
+| `@select-dropdown-height` | `optionHeight` | - |
+| `@select-background` | `selectorBg` | - |
+| `@select-clear-background` | `clearBg` | - |
+| `@select-selection-item-bg` | `multipleItemBg` | - |
+| `@select-selection-item-border-color` | `multipleItemBorderColor` | - |
+| `@select-single-item-height-lg` | `singleItemHeightLG` | - |
+| `@select-multiple-item-height` | `multipleItemHeight` | - |
+| `@select-multiple-item-height-lg` | `multipleItemHeightLG` | - |
+| `@select-multiple-item-spacing-half` | - | 已废弃 |
+| `@select-multiple-disabled-background` | `multipleSelectorBgDisabled` | - |
+| `@select-multiple-item-disabled-color` | `multipleItemColorDisabled` | - |
+| `@select-multiple-item-disabled-border-color` | `multipleItemBorderColorDisabled` | - |
### Skeleton 骨架屏