我使用前缀来区分我的样式和第三方类。不使用前缀时,下面的代码可以正常工作:
fixed h-[5px] bg-green top-0 left-0 z-1000
当使用前缀顶部和左侧样式时,tailwind css 文件中根本不会生成,而其他样式则正常。
tw:fixed tw:h-[5px] tw:bg-green tw:top-0 tw:left-0 tw:z-1000
更新:
我正在使用@tailwind
,tailwind.config
因为这是摆脱所有不必要的 Tailwind 样式的唯一方法。有一个第三方元素使用了 class outline
(以及一些 Tailwind 的基本类名),Tailwind 认为这是它的样式,所以 Tailwindoutline
在其 CSS 文件中生成了样式,这弄乱了界面。
我尝试过使用@import "tailwindcss" prefix(tw);
和其他组合,但这样所有垃圾样式都会出现在生成的 css 中,这会让事情变得混乱。
index.css
内容:
@config "../../tailwind.config.js";
@tailwind base;
@tailwind components;
@tailwind utilities;
/* ... */
tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
mode: "jit",
prefix: "tw",
content: ["./src/**/*.{js,jsx,ts,tsx,css}"],
theme: {
colors: {
'green': '#4287f5'
}
}
}