ant-design / antd-style

css-in-js library with antd v5 token system
https://ant-design.github.io/antd-style/
MIT License
219 stars 35 forks source link

🧐[问题]如何通过antd-style去覆盖antd中message、modal等非根节点插入组件的样式 #71

Closed jsoyoy closed 1 year ago

jsoyoy commented 1 year ago

🧐 问题描述

业务开发,基于antd的二次开发,message、modal需要重写样式,如何通过antd-style去进行样式覆盖呢?

💻 示例代码

🚑 其他信息

jsoyoy commented 1 year ago

💻 示例代码

Them.tsx

截屏2023-06-20 上午10 57 46

index.tsx

截屏2023-06-20 上午10 56 42 1

效果图

截屏2023-06-20 上午11 14 34

我现在的方案是通过ThemeProvider注入自定义的变量,然后在把需要覆写样式挂载到ThemWrapper这个包裹组件上。对应的Button这种组件能实现样式覆盖,但是对于message这种没有挂载到根节点的组件是不会生效的。请问有没有更好的方法去覆盖它的样式。

arvinxx commented 1 year ago

应该可以直接使用 ConfigProvider 的能力了。感觉可以不用放在 antd-style 里来做

image