首页 > 其他分享 >How to fix Tailwind CSS colors not work in Next.js All In One

How to fix Tailwind CSS colors not work in Next.js All In One

时间:2023-09-14 11:55:05浏览次数:44  
标签:const Tailwind fix work js colors article custom id

How to fix Tailwind CSS colors not work in Next.js All In One

Tailwind CSS & Next.js 13

error

import type { Config } from 'tailwindcss'

const config: Config = {
  content: [
    './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
    './src/components/**/*.{js,ts,jsx,tsx,mdx}',
    './src/app/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    colors: {
      transparent: 'transparent',
      current: 'currentColor',
      'white': '#ffffff',
      'custom-green': '#7e22ce',
      'custom-color': {
        100: '#cffafe',
        200: '#a5f3fc',
        300: '#67e8f9',
        400: '#22d3ee',
        500: '#06b6d4',
        600: '#0891b2',
        700: '#00ff00',// #7e22ce
        800: '#155e75',
        900: '#164e63',
      },
      // ...
    },
  },
  plugins: [],
}
export default config

async function Page() {
  const data = await getData({ id: 1});
  const {
    id,
    article,
  } = data.props;
  return (
    <div className="flex-column items-center justify-center p-6">
      <div className="m-6">Page article id = {id}</div>
      <div className="m-6 custom-green">custom-green ❌</div>
      <div className="m-6 border-red-500 custom-color-700">{JSON.stringify(article)}❌</div>
    </div>
  );
}

export default Page;

solution

// tailwind.config.js
module.exports = {
  theme: {
    colors: {
      indigo: '#5c6ac4',
      blue: '#007ace',
      red: '#de3618',
    }
  }
}

By default these colors are automatically shared by the textColor, borderColor, and backgroundColor utilities, so the above configuration would generate classes like .text-indigo, .border-blue, and .bg-red.

https://v1.tailwindcss.com/docs/customizing-colors

demos

http://localhost:3000/article

import type { Config } from 'tailwindcss'

const config: Config = {
  content: [
    './src/pages/**/*.{js,ts,jsx,tsx,mdx}',
    './src/components/**/*.{js,ts,jsx,tsx,mdx}',
    './src/app/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    extend: {
      backgroundImage: {
        'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
        'gradient-conic':
          'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
      },
    },
    colors: {
      transparent: 'transparent',
      current: 'currentColor',
      'white': '#ffffff',
      'custom-green': '#7e22ce',
      'custom-color': {
        100: '#cffafe',
        200: '#a5f3fc',
        300: '#67e8f9',
        400: '#22d3ee',
        500: '#06b6d4',
        600: '#0891b2',
        700: '#00ff00',// #7e22ce
        800: '#155e75',
        900: '#164e63',
      },
      // ...
    },
  },
  plugins: [],
}
export default config


async function Page() {
  const data = await getData({ id: 1});
  const {
    id,
    article,
  } = data.props;
  return (
    <div className="flex-column items-center justify-center p-6">
      <div className="m-6">Page article id = {id}</div>
      <div className="m-6 custom-green">custom-green ❌</div>
      <div className="m-6 text-custom-green">text-custom-green ✅</div>
      <div className="m-6 border-red-500 text-custom-color-700">{JSON.stringify(article)}</div>
    </div>
  );
}

export default Page;

image

(

标签:const,Tailwind,fix,work,js,colors,article,custom,id
From: https://www.cnblogs.com/xgqfrms/p/17701255.html

相关文章

  • [BT][Setting]如何在Framework层实现BT的自动配对
    https://blog.csdn.net/weixin_44343246/article/details/109768335[DESCRIPTION]客户有需求在没有屏和TP的情况下,如果有其他蓝牙对此设备进行配对,希望能自动完成配对动作,而不需要弹出需要用户确认的对话框。1Android手机平台上当对方发起配对时主要使用种配对方式:1.SSP......
  • Vectorworks 2022下载_Vectorworks2022SP3(3D建模软件) 功能介绍
    Vectorworks是工业设计软件全家桶其中的一款,参与到整个行业的三维图像一键设计和内部结构优化布局的过程之中,并且也会很快参与到页面功能创建,机械工程设计以及空间照明情况等方面的妥善安排,当然用户完全可以根据平台自身情况做好充足的渝北工作,以形成本地工作效率上的统筹优化安排......
  • Vectorworks2022中文版下载_Vectorworks2022最新下载 新功能介绍
    Vectorworks2022SP2是一款十分好用的3D建模设计软件,它给许多行业的人士带来了极大的帮助和便利。有了这款软件后,设计师们可以轻松解决眼前的问题,同时也是非常的适合建筑师在完全集成的BIM工作流程中进行素描、绘图和建模,并且该软件内还有着大量的实用工具,比如说草图、模型、分析......
  • vectorworks2022中文版下载(三维建模设计软件) 新功能介绍
    Vectorworks是一款功能强大的3d建模工具,被广泛应用于建筑、景观、灯光、机械等领域,软件可以跨平台操作,是欧美及日本等工业发达国家设计师的首选工具软件。Vectorworks提供了许多精简但强大的建筑及产品工业设计所需的工具模组;在建筑设计、景观设计、舞台及灯光设计、机械设计及渲......
  • Vectorworks中文版(行业设计软件)_Vectorworks下载 功能介绍
    软件功能1、多个绘图视图使用新的“启用多个视图”命令,您可以同时查看项目的视图,并且可以在一个视图窗格中开始工作,并在另一个视图窗格中完成工作。在视口,视图和可视性设置之间轻松切换以完成您所需的任务-只需设置您的窗格并一次查看它们。立即衡量设计更改对3D,平面图,剖面和立面......
  • VDSR-Accurate Image Super-Resolution Using Very Deep Convolutional Networks阅读
    AccurateImageSuper-ResolutionUsingVeryDeepConvolutionalNetworks(VDSR)阅读笔记(22.10.07)使用深度卷积网络的精确图像超分辨率摘要:使用一个非常深的卷积神经网络,灵感来源于VGG-Net。本文发现,网络深度增加可以显著提高准确性。本文模型最终使用了20个权重层。通过在深度网......
  • VERY DEEP CONVOLUTIONAL NETWORKS FOR LARGE
    (VGG)VERYDEEPCONVOLUTIONALNETWORKSFORLARGE-SCALEIMAGERECOGNITION阅读笔记(22.10.05)摘要:本文研究在大规模图像识别设置中卷积网络深度对其准确性的影响。主要贡献是对使用(3,3)卷积核的体系结构增加深度的网络进行全面评估,结果表明,深度推到16-19可以实现对现有技术配置的显......
  • Bug库____org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorr
    Bug:使用到了spring的jdbctemplate模板使用到以下template.queryForObject(sql,requiredType)template.queryForList(sql,elementType,args)报以下错误org.springframework.jdbc.IncorrectResultSetColumnCountException:Incorrectcolumncount:expected1,actual3检查完......
  • BUG(Spring Framework JdbcTemplate) org.springframework.jdbc.IncorrectResultSetCo
    一.SpringFramework queryForObject问题1.spring4.0之前使用使用jdbctemplate的queryForObject(Stringsql,Object[]args,RowMapper<T>rowMapper)直接放入class类型会报错org.springframework.jdbc.IncorrectResultSetColumnCountException:Incorrectcolumncount:expec......
  • Working With Strings In Python.
    #字符串操作在Python中,`string`是一种不可变的数据类型,用于表示文本或字符序列,可以使用单引号或双引号将字符串括起来。<fontcolor="#C7EDCC">所有修改和生成字符串的操作的实现方法都是另一个内存片段中新生成一个字符串对象。</font>##创建字符串```pystr1="Lefti......