【问题标题】:How to use theme() function in config (tailwind)如何在配置中使用 theme() 函数(顺风)
【发布时间】:2021-11-02 21:10:21
【问题描述】:

我正在尝试创建 1 个可重复使用的间隙变量,我可以在我有多个按钮彼此相邻的任何地方使用它。而不是使用gap-3 我只想使用gap-buttons

module.exports = {
  theme: {
    extend: {
      gap: {
        buttons: theme(theme.gap.3),
      },
    },
  },
};

我得到的错误是Maximum call stack size exceeded。我试过buttons: (theme) => theme(theme.gap.3) 也没有用。还有颜色,它不起作用......

module.exports = {
  theme: {
    extend: {
      colors: {
       alert: theme => theme('colors.red')
      }
    },
  },
};

【问题讨论】:

  • 嗨,我的回答有帮助吗?

标签: css sass tailwind-css tailwind-in-js tailwind-ui


【解决方案1】:

我的一个项目中确实有这种代码,不确定它是否有帮助(那个是tailwind v1,没有extend

borderColor: (theme) => ({
  ...theme('colors'),
  default: theme('colors.gray.300', 'currentColor'),
}),

你的代码看起来像这样

colors: (theme) => ({
  alert: theme('colors.red')
})

【讨论】:

    猜你喜欢
    • 2021-05-30
    • 1970-01-01
    • 2021-12-15
    • 2022-07-01
    • 2021-05-04
    • 2022-01-16
    • 2021-10-30
    • 2021-01-02
    • 1970-01-01
    相关资源
    最近更新 更多