Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

默认预设与 Tailwind 不兼容,失去继承属性。 #2961

Closed
4 tasks done
dufu1991 opened this issue Aug 8, 2023 · 2 comments
Closed
4 tasks done

默认预设与 Tailwind 不兼容,失去继承属性。 #2961

dufu1991 opened this issue Aug 8, 2023 · 2 comments

Comments

@dufu1991
Copy link

dufu1991 commented Aug 8, 2023

UnoCSS version

0.54.2

Describe the bug

我使用默认预设,继承自 @unocss/preset-wind 时发现这个预设并没有与 Tailwind 一致。在文件 packages/reset/tailwind-compat.css 和 packages/reset/tailwind.css 中 border-color 是固定写为 #e5e7eb 。

*,
::before,
::after {
  box-sizing: border-box; /* 1 */
  border-width: 0; /* 2 */
  border-style: solid; /* 2 */
  border-color: #e5e7eb; /* 2 */
}

但是 Tailwind 中是这样的。https://github.com/tailwindlabs/tailwindcss/blob/05e307bb6c562884877ea52b0d147bcecc4df3f6/src/css/preflight.css

*,
::before,
::after {
  box-sizing: border-box; /* 1 */
  border-width: 0; /* 2 */
  border-style: solid; /* 2 */
  border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
}

这样就导致 border-color 与 Tailwind 不兼容,并且失去了继承。

Reproduction

https://github.com/tailwindlabs/tailwindcss/blob/05e307bb6c562884877ea52b0d147bcecc4df3f6/src/css/preflight.css

System Info

No response

Validations

@zyyv
Copy link
Member

zyyv commented Aug 8, 2023

https://github.com/tailwindlabs/tailwindcss/blob/4f0bb0b73ad7fb82e626ca7c2ddced0d0f0edc7c/stubs/config.full.js#L84C57-L84C57

If you not change the default color theme, borderColor.DEFAULT === #e5e7eb

@dufu1991
Copy link
Author

dufu1991 commented Aug 9, 2023

However, Tailwind also has a currentColor utility, which allows the border color to inherit the text color when no border color is set. When I created the project using pnpm create stdf@latest, I noticed that the border color of the "+10" button is inconsistent when selecting Tailwind and UnoCSS separately.

This is because Tailwind compiles to:

*, ::before, ::after {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: currentColor;
}

However, UnoCSS compiles to:

*, ::before, ::after {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: #e5e7eb;
}

In the Tailwind version, the border-color is set to currentColor, which means it will inherit the text color. On the other hand, the UnoCSS version directly sets the border-color to #e5e7eb.

I still hope to have a currentColor as a fallback solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants