next.js Shadcn UI安装打破子Tailwind CSS

dffbzjpn  于 2023-06-22  发布在  其他
关注(0)|答案(1)|浏览(261)

Shadcn UI(https://ui.shadcn.com/)一直工作得很好,直到昨天我在本地主机上运行NextJS应用程序,没有顺风工作。为了调试这个问题,我在一个全新的文件位置创建了一个空白的NextJS 13应用程序,一切正常; tailwind正在处理默认的nextJS 13页面。然后我就跑了

npx shadcn-ui init

而不需要安装任何部件。这并没有吐出任何错误,但后来没有一个顺风造型工作了。
安装后的我的tailwind.config.js:

/** @type {import('tailwindcss').Config} */
module.exports = {
  darkMode: ["class"],
  content: [
    './pages/**/*.{ts,tsx}',
    './components/**/*.{ts,tsx}',
    './app/**/*.{ts,tsx}',
    ],
  theme: {
    container: {
      center: true,
      padding: "2rem",
      screens: {
        "2xl": "1400px",
      },
    },
    extend: {
      colors: {
        border: "hsl(var(--border))",
        input: "hsl(var(--input))",
        ring: "hsl(var(--ring))",
        background: "hsl(var(--background))",
        foreground: "hsl(var(--foreground))",
        primary: {
          DEFAULT: "hsl(var(--primary))",
          foreground: "hsl(var(--primary-foreground))",
        },
        secondary: {
          DEFAULT: "hsl(var(--secondary))",
          foreground: "hsl(var(--secondary-foreground))",
        },
        destructive: {
          DEFAULT: "hsl(var(--destructive))",
          foreground: "hsl(var(--destructive-foreground))",
        },
        muted: {
          DEFAULT: "hsl(var(--muted))",
          foreground: "hsl(var(--muted-foreground))",
        },
        accent: {
          DEFAULT: "hsl(var(--accent))",
          foreground: "hsl(var(--accent-foreground))",
        },
        popover: {
          DEFAULT: "hsl(var(--popover))",
          foreground: "hsl(var(--popover-foreground))",
        },
        card: {
          DEFAULT: "hsl(var(--card))",
          foreground: "hsl(var(--card-foreground))",
        },
      },
      borderRadius: {
        lg: "var(--radius)",
        md: "calc(var(--radius) - 2px)",
        sm: "calc(var(--radius) - 4px)",
      },
      keyframes: {
        "accordion-down": {
          from: { height: 0 },
          to: { height: "var(--radix-accordion-content-height)" },
        },
        "accordion-up": {
          from: { height: "var(--radix-accordion-content-height)" },
          to: { height: 0 },
        },
      },
      animation: {
        "accordion-down": "accordion-down 0.2s ease-out",
        "accordion-up": "accordion-up 0.2s ease-out",
      },
    },
  },
  plugins: [require("tailwindcss-animate")],
}

滴注后我的用途

import { ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
 
export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

the default page after instillation
编辑:经过一些测试,问题似乎来自globals.css和tailwind.config.js,但仍然不确定它们是什么。

mjqavswn

mjqavswn1#

如果您的情况与我的类似,并且您使用src文件夹 Package 应用程序文件夹,则问题来自tailwind配置文件。

/** @type {import('tailwindcss').Config} */
module.exports = {
  darkMode: ["class"],
  content: [
    './pages/**/*.{ts,tsx}',
    './components/**/*.{ts,tsx}',
    './app/**/*.{ts,tsx}',
    ],

这就是你所拥有的。但是,内容Map到错误的目录。使用此更新内容数组中的字符串。

content: [
    './src/app/**/*.{ts,tsx}', './src/components/**/*.{ts,tsx}',
    ],

相关问题