diff --git a/.dumi/theme/common/styles/Common.tsx b/.dumi/theme/common/styles/Common.tsx
index c2f9cf7f2b67..2744394b203b 100644
--- a/.dumi/theme/common/styles/Common.tsx
+++ b/.dumi/theme/common/styles/Common.tsx
@@ -1,77 +1,86 @@
-import { css, Global } from '@emotion/react';
import React from 'react';
+import { css, Global } from '@emotion/react';
import { useTheme } from 'antd-style';
+import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
export default () => {
const { anchorTop } = useTheme();
+ React.useInsertionEffect(() => {
+ updateCSS(`@layer global, antd;`, 'site-global', {
+ prepend: true,
+ });
+ }, []);
+
return (
);
};
diff --git a/.dumi/theme/layouts/GlobalLayout.tsx b/.dumi/theme/layouts/GlobalLayout.tsx
index ab1ab33f28c9..c45a6c6881df 100644
--- a/.dumi/theme/layouts/GlobalLayout.tsx
+++ b/.dumi/theme/layouts/GlobalLayout.tsx
@@ -204,6 +204,7 @@ const GlobalLayout: React.FC = () => {
diff --git a/.dumi/theme/plugin.ts b/.dumi/theme/plugin.ts
index bb544dc16e60..f30a91caa07b 100644
--- a/.dumi/theme/plugin.ts
+++ b/.dumi/theme/plugin.ts
@@ -169,7 +169,8 @@ const RoutesPlugin = (api: IApi) => {
const matchRegex = /
+);
+```
+
+antd styles will be encapsulated in `@layer` to lower the priority:
+
+```diff
+++ @layer antd {
+ :where(.css-bAMboO).ant-btn {
+ color: #fff;
+ }
+++ }
+```
+
## Compatible adjustment
-The CSS-in-JS feature of Ant Design uses the ":where" selector by default to lower the CSS selector specificity, reducing the additional cost of adjusting custom styles when upgrading for users. However, the compatibility of the ":where" syntax is relatively poor in older browsers ([compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/:where#browser_compatibility)). In certain scenarios, if you need to support older browsers (or encounter priority conflicts like TailwindCSS), you can use `@ant-design/cssinjs` to disable the default lowering of specificity (please ensure version consistency with antd).
+The CSS-in-JS feature of Ant Design uses the ":where" selector by default to lower the CSS selector specificity, reducing the additional cost of adjusting custom styles when upgrading for users. However, the compatibility of the ":where" syntax is relatively poor in older browsers ([compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/:where#browser_compatibility)). In certain scenarios, if you need to support older browsers, you can use `@ant-design/cssinjs` to disable the default lowering of specificity (please ensure version consistency with antd).
```tsx
import { StyleProvider } from '@ant-design/cssinjs';
@@ -147,3 +171,91 @@ root.render(
,
);
```
+
+## Compatible with Third-party Style Libraries
+
+In some cases, you may need antd to coexist with other style libraries, such as `Tailwind CSS`, `Emotion`, `styled-components`, etc. Unlike traditional CSS solutions, these third-party libraries are often not easy to override antd styles by increasing CSS selector priority. You can configure `@layer` for antd to lower its CSS selector weight, and arrange `@layer` order to solve style override problems:
+
+### antd config `@layer`
+
+```tsx
+import { StyleProvider } from '@ant-design/cssinjs';
+
+export default () => (
+
+
+
+);
+```
+
+### TailwindCSS Arrange `@layer`
+
+In global.css, adjust `@layer` to control the order of style override. Place `tailwind-base` before `antd`:
+
+```less
+@layer tailwind-base, antd;
+
+@layer tailwind-base {
+ @tailwind base;
+}
+@tailwind components;
+@tailwind utilities;
+```
+
+### reset.css
+
+If you use antd's `reset.css` style, you need to specify `@layer` for it to prevent the style from overriding antd:
+
+```less
+@layer reset, antd;
+
+@import url(reset.css) layer(reset);
+```
+
+### With other CSS-in-JS libraries
+
+After configuring `@layer` for antd, you don't need to do any additional configuration for other CSS-in-JS libraries. Your CSS-in-JS can completely override antd styles.
+
+### SSR Scene
+
+When using SSR, styles are often rendered inline in HTML through ``. At this time, please make sure that the styles with the specified `@layer` priority order are loaded before `@layer` is used.
+
+#### ❌ Wrong
+
+```html
+