默认颜色不适用于“ tailwind.macro”

时间:2019-09-22 06:21:32

标签: create-react-app postcss emotion tailwind-css

我有一个React应用,试图让tailwind.macro在其中运行 emotion表示法。 我正在使用customize-cra重新连接应用程序,而${tw一切}都可以正常运行。 但是,它似乎没有继承原始的颜色主题 tailwind,我正在寻找解决方案。
这是项目:
https://github.com/minagawah/cra-ts-emotion-tailwind-solution

如自述文件所述,我尝试了 (1)using babel macro, 和(2)using PostCSS plugins
我以为是backgroundSize的问题 正如在 this issue,但没有运气。

这是我在应用程序中使用tw宏表示法的方式:

./src/App.tsx

import styled from '@emotion/styled';
import tw from 'tailwind.macro';

const Button = styled.button`
  ${tw`mt-4 p-2 text-white bg-red-600`}
`;

目前有效 because I applied a workaround 为此。

它应该应用默认的顺风主题,而不应用我已经解决的方法。
我一直在尝试找出方法,但到目前为止,还没有运气...

请,我迫切需要帮助...

编辑:(2019-09-22)
在为bg-red工作时,我发现默认情况下没有bg-red这样的东西……这是我需要手动添加的tailwind.config.js

问题已解决。

module.exports = {
  theme: {
    extend: {
      colors: {
        red: '#e53e3e',
      },
    },
  },
  variants: {},
  plugins: [],
}

2 个答案:

答案 0 :(得分:0)

我通过从tailwind.config.js中的tailwindcss github复制默认值来解决了相同的问题。 这是tailwindcss默认值的链接 https://github.com/tailwindcss/tailwindcss/blob/master/stubs/defaultConfig.stub.js#L5

答案 1 :(得分:0)

  theme: {
    extend: {
      colors: {
        red: '#e53e3e',
      },
    },
  },
  variants: {},
  plugins: [],
}