Skip to content

Commit

Permalink
fix: tailwindcss reset Image style (#39914)
Browse files Browse the repository at this point in the history
* fix: tailwindcss reset

* docs: more info

* chore: comment
  • Loading branch information
zombieJ committed Dec 30, 2022
1 parent 5f40fe8 commit da03c1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions components/image/style/index.ts
Expand Up @@ -198,6 +198,13 @@ export const genImagePreviewStyle: GenerateStyle<ImageToken> = (token: ImageToke
...genBoxStyle(),
transition: `transform ${motionDurationSlow} ${motionEaseOut} 0s`,

// https://github.com/ant-design/ant-design/issues/39913
// TailwindCSS will reset img default style.
// Let's set back.
display: 'flex',
justifyContent: 'center',
alignItems: 'center',

'&::before': {
display: 'inline-block',
width: 1,
Expand Down
2 changes: 1 addition & 1 deletion docs/react/compatible-style.en-US.md
Expand Up @@ -7,7 +7,7 @@ Ant Design supports the last 2 versions of modern browsers. If you need to be co

### Compatible adjustment

Ant Design default using CSS-in-JS with `:where` Selector to reduce priority to avoid user additional adjust style cost when updating. If you want to support old browser, you can use `@ant-design/cssinjs` to adjust this behavior (Please note keep version align with antd):
Ant Design default using CSS-in-JS with `:where` Selector to reduce priority to avoid user additional adjust style cost when updating. If you want to support old browser (or some other CSS framework selector priority conflict like TailwindCSS), you can use `@ant-design/cssinjs` to adjust this behavior (Please note keep version align with antd):

```tsx
import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion docs/react/compatible-style.zh-CN.md
Expand Up @@ -7,7 +7,7 @@ Ant Design 支持最近 2 个版本的现代浏览器。如果你需要兼容旧

### `:where` 选择器

Ant Design 的 CSS-in-JS 默认通过 `:where` 选择器降低 CSS Selector 优先级,以减少用户升级时额外调整自定义样式成本。在某些场景下你如果需要支持的旧版浏览器,你可以使用 `@ant-design/cssinjs` 取消默认的降权操作(请注意版本保持与 antd 一致):
Ant Design 的 CSS-in-JS 默认通过 `:where` 选择器降低 CSS Selector 优先级,以减少用户升级时额外调整自定义样式成本。在某些场景下你如果需要支持的旧版浏览器(或者如 TailwindCSS 优先级冲突),你可以使用 `@ant-design/cssinjs` 取消默认的降权操作(请注意版本保持与 antd 一致):

```tsx
import React from 'react';
Expand Down

0 comments on commit da03c1e

Please sign in to comment.