diff --git a/components/input/style/index.ts b/components/input/style/index.ts index c90e9df438..cf0ab255c8 100644 --- a/components/input/style/index.ts +++ b/components/input/style/index.ts @@ -881,4 +881,7 @@ export default genStyleHooks( ]; }, initComponentToken, + { + resetFont: false, + }, ); diff --git a/components/style/index.ts b/components/style/index.ts index 2915ea84b8..a6e1ded6f7 100644 --- a/components/style/index.ts +++ b/components/style/index.ts @@ -107,29 +107,34 @@ export const genCommonStyle = ( token: DerivativeToken, componentPrefixCls: string, rootCls?: string, + resetFont?: boolean, ): CSSObject => { - const { fontFamily, fontSize } = token; - const prefixSelector = `[class^="${componentPrefixCls}"], [class*=" ${componentPrefixCls}"]`; const rootPrefixSelector = rootCls ? `.${rootCls}` : prefixSelector; + const resetStyle: CSSObject = { + boxSizing: 'border-box', + + '&::before, &::after': { + boxSizing: 'border-box', + }, + }; + + let resetFontStyle: CSSObject = {}; + + if (resetFont !== false) { + resetFontStyle = { + fontFamily: token.fontFamily, + fontSize: token.fontSize, + }; + } + return { [rootPrefixSelector]: { - fontFamily, - fontSize, - boxSizing: 'border-box', + ...resetFontStyle, + ...resetStyle, - '&::before, &::after': { - boxSizing: 'border-box', - }, - - [prefixSelector]: { - boxSizing: 'border-box', - - '&::before, &::after': { - boxSizing: 'border-box', - }, - }, + [prefixSelector]: resetStyle, }, }; }; diff --git a/components/theme/util/genComponentStyleHook.tsx b/components/theme/util/genComponentStyleHook.tsx index a501a1966e..8dee7e34d6 100644 --- a/components/theme/util/genComponentStyleHook.tsx +++ b/components/theme/util/genComponentStyleHook.tsx @@ -133,6 +133,7 @@ export default function genComponentStyleHook( getDefaultToken?: GetDefaultToken, options: { resetStyle?: boolean; + resetFont?: boolean; // Deprecated token key map [["oldTokenKey", "newTokenKey"], ["oldTokenKey", "newTokenKey"]] deprecatedTokens?: [ComponentTokenKey, ComponentTokenKey][]; /** @@ -243,7 +244,9 @@ export default function genComponentStyleHook( }); flush(component, componentToken); return [ - options.resetStyle === false ? null : genCommonStyle(mergedToken, prefixCls, rootCls), + options.resetStyle === false + ? null + : genCommonStyle(mergedToken, prefixCls, rootCls, options.resetFont), styleInterpolation, ]; }, @@ -378,6 +381,7 @@ export const genStyleHooks = ( getDefaultToken?: GetDefaultToken, options?: { resetStyle?: boolean; + resetFont?: boolean; deprecatedTokens?: [ComponentTokenKey, ComponentTokenKey][]; /** * Component tokens that do not need unit.