nextui-org / nextui

🚀 Beautiful, fast and modern React UI library.
https://nextui.org
MIT License
21.44k stars 1.39k forks source link

[BUG] - No Styling when setting up NextUI in an existing project #3082

Closed daniel-aziz closed 3 months ago

daniel-aziz commented 3 months ago

NextUI Version

2.3.6

Describe the bug

I have a Next.js 14 application using app router. i have tried to integrate manully Next UI, followed the docs and set up using Global Installation. I have installed version 2.3.6 but i have no styling in the UI components

I'm importing component as the following

import { Input as NextUIInput } from "@nextui-org/react";
import type { InputProps as NextUIInputProps } from "@nextui-org/react";

const Input = NextUIInput;
type InputProps = NextUIInputProps;

export type { InputProps };
export { Input };

im also tried importing from @nextui-org/input but same results

after digging around, and trying to set up or fork other projects, i installed manually, the following dependencies

   "@nextui-org/system": "2.1.0",
    "@nextui-org/theme": "2.2.0",

I got styling at last.

i did tried to update those dpendincies to the last version to

  "@nextui-org/system": "2.1.2",
    "@nextui-org/theme": "2.2.3",

but i get no styling, so i reverted back

my current dependencies

"dependencies": {
    "@aws-sdk/client-s3": "3.583.0",
    "@aws-sdk/s3-request-presigner": "3.583.0",
    "@clerk/elements": "0.4.5",
    "@clerk/nextjs": "5.0.12",
    "@hookform/resolvers": "3.4.0",
    "@next/bundle-analyzer": "14.2.3",
    "@nextui-org/react": "2.3.6",
    "@nextui-org/system": "2.1.0",
    "@nextui-org/theme": "2.2.0",
    "@t3-oss/env-nextjs": "^0.10.1",
    "@tanstack/react-query": "^5.36.0",
    "@trpc/client": "next",
    "@trpc/next": "next",
    "@trpc/react-query": "next",
    "@trpc/server": "next",
    "@types/react-lottie": "1.2.10",
    "drizzle-orm": "^0.30.10",
    "drizzle-zod": "0.5.1",
    "framer-motion": "11.1.9",
    "next": "^14.2.3",
    "nodemailer": "6.9.13",
    "pino": "9.1.0",
    "postgres": "^3.4.4",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-hook-form": "7.51.4",
    "react-lottie": "1.2.4",
    "sonner": "1.4.41",
    "superjson": "^2.2.1",
    "zod": "^3.23.7"
  },
  "devDependencies": {
    "@faker-js/faker": "8.4.1",
    "@playwright/test": "1.44.0",
    "@svgr/webpack": "8.1.0",
    "@testing-library/react": "15.0.7",
    "@types/eslint": "^8.56.10",
    "@types/node": "^20.12.11",
    "@types/react": "^18.3.1",
    "@types/react-dom": "^18.3.0",
    "@typescript-eslint/eslint-plugin": "^7.9.0",
    "@typescript-eslint/parser": "^7.8.0",
    "@vitejs/plugin-react": "4.2.1",
    "autoprefixer": "10.4.19",
    "dotenv": "16.4.5",
    "drizzle-kit": "^0.21.2",
    "eslint": "8.56.0",
    "eslint-config-next": "^14.2.3",
    "eslint-plugin-drizzle": "^0.2.3",
    "pg": "^8.11.5",
    "postcss": "^8.4.38",
    "prettier": "^3.2.5",
    "prettier-plugin-tailwindcss": "^0.5.14",
    "tailwindcss": "^3.4.3",
    "tsx": "4.10.5",
    "typescript": "^5.4.5",
    "vitest": "1.6.0"
  },

tell where have i gone worng in the installation process. my set up was

  1. pnpm install @nextui-org/react framer-motion
  2. configuring tailwind css setup as the doc
  3. wrapped my app in NextUiProvider
  4. set up pnpm in .npmrc

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. set up next js 14 project
  2. setup as documented up

Expected behavior

should be styling

Screenshots or Videos

No response

Operating System Version

MacOS 14.4.1

Browser

Chrome

linear[bot] commented 3 months ago

ENG-893 [BUG] - No Styling when setting up NextUI in an existing project

soyricardodev commented 3 months ago

did u updated your tailwindcss config? Tailwindcss setup Provider setup

if u can provide a repo to see the problem i can help u

daniel-aziz commented 3 months ago

did u updated your tailwindcss config? Tailwindcss setup Provider setup

if u can provide a repo to see the problem i can help u

Unfortrunnaly i cannot provide a repo, as it is private.

Provider setup at layout.tsx

"use client";
import "~/styles/globals.css";
import { NextUIProvider } from "@nextui-org/react";
import Layout from "src/app/_components/Layout";
import React from "react";
import TrpcProvider from "~/app/_trpc/TrpcProvider";
import { ClerkProvider } from "@clerk/nextjs";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <head>
        <title>Portal</title>
        <link
          rel="icon"
          type="image/png"
          sizes="32x32"
          href="/favicon-32x32.png"
        />
        <link
          rel="icon"
          type="image/png"
          sizes="16x16"
          href="/favicon-16x16.png"
        />
      </head>
      <body>
        <ClerkProvider>
          <TrpcProvider>
            <NextUIProvider>
              <Layout>{children}</Layout>
            </NextUIProvider>
          </TrpcProvider>
        </ClerkProvider>
      </body>
    </html>
  );
}

Tailwind config

import { type Config } from "tailwindcss";
import { nextui } from "@nextui-org/react";
import { Colors, GradientColors } from "./src/styles/colors";
import { BorderRadius, BoxShadow } from "./src/styles/layout";

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./src/**/*.{js,ts,jsx,tsx,mdx}",
    "./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
    colors: {
      ...Colors,
    },
    backgroundImage: {
      ...GradientColors,
    },
    boxShadow: {
      ...BoxShadow,
    },
    borderRadius: {
      ...BorderRadius,
    },
    fontSize: {
      "2xs": ["0.73rem", "1.05rem"], // 11px
      xs: ["0.86rem", "1.25rem"], // 13px
      sm: ["0.93rem", "1.34rem"], // 14px
      base: ["1rem", "1.44rem"], // 15px
      "2xl": ["1.60rem", "2.30rem"], // 24px
      "3xl": ["2.26rem", "3.26rem"], // 34px
      "4xl": ["2.66rem", "3.84rem"], // 40px
    },
  },
  darkMode: "class",
  plugins: [
    nextui({
      themes: {
        light: {
          colors: {
            primary: {
              DEFAULT: Colors.lavender[700],
            },
          },
        },
      },
    }),
  ],
} satisfies Config;

My app folder is located under agency folder, this is the structure.

Root -> portals -> agency -> src -> app -> layout.tsx

all package.json, tailwind.config.ts node_modules are located under agency folder

ericljiang commented 3 months ago

In your Tailwind config, change this line

"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}"

to this

"./node_modules/@nextui-org/react/node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}"

I'm interested to hear from the NextUI team if the installation instructions are incorrect or if we have set up something incorrectly and the original configuration is supposed to work.

wingkwong commented 3 months ago

@daniel-aziz the steps look correct. please share a minimal reproducible example for us to investigate @ericljiang "./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}" is correct. if you are using pnpm, you need to add public-hoist-pattern[]=*@nextui-org/* to .npmrc.

daniel-aziz commented 3 months ago

@wingkwong @ericljiang You can close this. i'm adding my solution for anyone wondering.

I have created the app with pnpm create t3-app@latest and changed the file structure as listed under.

my node_modules path was probably incorrect.

i changed from this

 "./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",

to this

 "../../node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",

this is my file structure

Root
├── node_modules
├── portals
│   ├── agency
│   │   ├── src
│   │   │   ├── app
│   │   │   │   ├── layout.tsx
│   │   ├── tailwind.config.ts