<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dhruv Prajapati</title>
    <description>The latest articles on DEV Community by Dhruv Prajapati (@dgamer007).</description>
    <link>https://dev.to/dgamer007</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F886376%2Fc5a2da0c-509c-44d7-8f28-fc28f72d91d6.PNG</url>
      <title>DEV Community: Dhruv Prajapati</title>
      <link>https://dev.to/dgamer007</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dgamer007"/>
    <language>en</language>
    <item>
      <title>Nx Workspace Guide (v20): Next.js + React Component Library + ShadCN Integration + Tailwind CSS (v4)</title>
      <dc:creator>Dhruv Prajapati</dc:creator>
      <pubDate>Tue, 18 Mar 2025 10:18:15 +0000</pubDate>
      <link>https://dev.to/dgamer007/-3i9l</link>
      <guid>https://dev.to/dgamer007/-3i9l</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/dgamer007" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F886376%2Fc5a2da0c-509c-44d7-8f28-fc28f72d91d6.PNG" alt="dgamer007"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/dgamer007/nx-workspace-guidev20-nextjs-react-component-library-shadcn-integration-tailwindcss-v4-1908" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Nx Workspace Guide(v20): Next.js + React Component Library + ShadCN Integration + Tailwindcss (v4)&lt;/h2&gt;
      &lt;h3&gt;Dhruv Prajapati ・ Mar 18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#nxworkspace&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#shadcn&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#react&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#nextjs&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>nxworkspace</category>
      <category>shadcn</category>
      <category>react</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Nx Workspace Guide(v20): Next.js + React Component Library + ShadCN Integration + Tailwindcss (v4)</title>
      <dc:creator>Dhruv Prajapati</dc:creator>
      <pubDate>Tue, 18 Mar 2025 08:49:01 +0000</pubDate>
      <link>https://dev.to/dgamer007/nx-workspace-guidev20-nextjs-react-component-library-shadcn-integration-tailwindcss-v4-1908</link>
      <guid>https://dev.to/dgamer007/nx-workspace-guidev20-nextjs-react-component-library-shadcn-integration-tailwindcss-v4-1908</guid>
      <description>&lt;p&gt;Explore the full setup and code on GitHub:  &lt;a href="https://github.com/alias404/nx-workspace-tutorial" rel="noopener noreferrer"&gt;https://github.com/alias404/nx-workspace-tutorial&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Modern web development demands efficient project structuring and component reusability. Nx provides a robust monorepo solution. Combining it with Next.js, a React component library leveraging Shadcn UI, and Tailwind CSS v4 can significantly streamline your workflow.&lt;/p&gt;

&lt;p&gt;This guide provides a detailed walkthrough for setting up an Nx monorepo incorporating Next.js, a React component library with Shadcn UI, and Tailwind CSS v4. The steps outlined here have been created and tested with the following specific versions of frameworks and libraries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node.js: v22.14.0
Yarn: v4.7.0
Nx: v20.6.0
Tailwind CSS: v4.0.14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Please note that steps might slightly differ for different versions of these frameworks and libraries. Ensure you are using the specified versions or adapt the instructions accordingly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Step 1: Initialize the Nx Workspace
&lt;/h2&gt;

&lt;p&gt;Start by creating a new Nx workspace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-nx-workspace@latest &lt;span class="nt"&gt;--pm&lt;/span&gt; yarn

✔ Where would you like to create your workspace? · my-workspace
✔ Which stack &lt;span class="k"&gt;do &lt;/span&gt;you want to use? · none
✔ Would you like to use Prettier &lt;span class="k"&gt;for &lt;/span&gt;code formatting? · No
✔ Which CI provider would you like to use? · skip
✔ Would you like remote caching to make your build faster? · skip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this guide, I have chosen yarn as my package manager. However, you can choose any package manager of your choice (npm, pnpm).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-workspace

&lt;span class="c"&gt;# Optional&lt;/span&gt;
&lt;span class="c"&gt;# Update Yarn to the stable version and install dependencies:&lt;/span&gt;

yarn &lt;span class="nb"&gt;set &lt;/span&gt;version stable
yarn &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clean up the initial workspace structure by removing the default &lt;code&gt;packages&lt;/code&gt; directory and its reference in &lt;code&gt;package.json&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Generate Projects
&lt;/h2&gt;

&lt;p&gt;Install necessary Nx plugins:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx add @nx/next
npx nx add @nx/react
npx nx add @nx/js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the Next.js application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx g @nx/next:app apps/website

✔ What unit &lt;span class="nb"&gt;test &lt;/span&gt;runner should be used? · none
✔ Which E2E &lt;span class="nb"&gt;test &lt;/span&gt;runner would you like to use? · none
✔ Would you like to use the App Router &lt;span class="o"&gt;(&lt;/span&gt;recommended&lt;span class="o"&gt;)&lt;/span&gt;? &lt;span class="o"&gt;(&lt;/span&gt;Y/n&lt;span class="o"&gt;)&lt;/span&gt; · &lt;span class="nb"&gt;false&lt;/span&gt;
✔ Would you like to use &lt;span class="sb"&gt;`&lt;/span&gt;src/&lt;span class="sb"&gt;`&lt;/span&gt; directory? &lt;span class="o"&gt;(&lt;/span&gt;Y/n&lt;span class="o"&gt;)&lt;/span&gt; · &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the React component library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx g @nx/react:library libs/ui

✔ Which stylesheet format would you like to use? · none
✔ Which bundler would you like to use to build the library? Choose &lt;span class="s1"&gt;'none'&lt;/span&gt; to skip build setup. · vite
✔ Which linter would you like to use? · none
✔ What unit &lt;span class="nb"&gt;test &lt;/span&gt;runner should be used? · none
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the TypeScript utility library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx g @nx/js:lib libs/utils &lt;span class="nt"&gt;--preset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ts

✔ Which bundler would you like to use to build the library? Choose &lt;span class="s1"&gt;'none'&lt;/span&gt; to skip build setup. · none
✔ Which linter would you like to use? · none
✔ What unit &lt;span class="nb"&gt;test &lt;/span&gt;runner should be used? · none
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clean up any boilerplate code generated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Configure Tailwind CSS v4 for the Next.js App (&lt;code&gt;apps/website&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;This step focuses on configuring Tailwind CSS v4 specifically for the &lt;code&gt;apps/website&lt;/code&gt; application, which is our Next.js project.&lt;/p&gt;

&lt;p&gt;Upgrade Tailwind CSS to v4 and remove &lt;code&gt;autoprefixer&lt;/code&gt; within the &lt;code&gt;apps/website&lt;/code&gt; project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn remove autoprefixer
yarn add tailwindcss@latest @tailwindcss/postcss@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;postcss.config.js&lt;/code&gt; within the &lt;code&gt;apps/website&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- postcss.config.js (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ postcss.config.js (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -1,11 +1,7 @@&lt;/span&gt;
&lt;span class="gd"&gt;-const { join } = require('path');
-
&lt;/span&gt; module.exports = {
   plugins: {
&lt;span class="gd"&gt;-    tailwindcss: {
-      config: join(__dirname, 'tailwind.config.js'),
-    },
-    autoprefixer: {},
&lt;/span&gt;&lt;span class="gi"&gt;+    '@tailwindcss/postcss': {}
&lt;/span&gt;   },
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Delete &lt;code&gt;tailwind.config.js&lt;/code&gt; within the &lt;code&gt;apps/website&lt;/code&gt; directory. Clear the content of &lt;code&gt;apps/website/src/pages/styles.css&lt;/code&gt;. This ensures that we are starting with a clean slate for our Next.js application's styling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Set Up Shadcn UI (CLI Support for Latest Configurations)
&lt;/h2&gt;

&lt;p&gt;This step focuses on setting up Shadcn UI within our React component library (&lt;code&gt;libs/ui&lt;/code&gt;). We're prioritizing CLI support to ensure we have access to the latest component configurations and styles, as the manual approach in Shadcn's documentation can sometimes lag behind the most recent updates.&lt;/p&gt;

&lt;p&gt;To initialize Shadcn in a folder, the CLI expects a framework setup to be present. Since we are initializing it at the workspace root, which doesn't directly correspond to a framework, we create a temporary &lt;code&gt;vite.config.js&lt;/code&gt; to simulate this environment. This allows the Shadcn CLI to detect a valid setup and proceed with initialization.&lt;/p&gt;

&lt;p&gt;Create &lt;code&gt;libs/ui/src/globals.css&lt;/code&gt; with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"tailwindcss"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Temporarily create &lt;code&gt;vite.config.js&lt;/code&gt; in the workspace root. Update the root &lt;code&gt;tsconfig.json&lt;/code&gt; with aliases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- tsconfig.json (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ tsconfig.json (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -7,3 +7,10 @@&lt;/span&gt;
       "path": "./libs/utils"
     }
   ],
&lt;span class="gi"&gt;+  "compilerOptions": {
+    "baseUrl": ".",
+    "paths": {
+      "@/*": ["./*"]
+    }
+  }
&lt;/span&gt; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Shadcn initialization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx shadcn@latest init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This step will generate the components.json file and, importantly, automatically update the &lt;code&gt;libs/ui/src/globals.css&lt;/code&gt; file to include the latest Tailwind CSS theme, CSS variables, and other necessary configurations based on the options you selected during the initialization process. This ensures your component library starts with the most up-to-date styles.&lt;/p&gt;

&lt;p&gt;Delete the temporary &lt;code&gt;vite.config.js&lt;/code&gt;. Update &lt;code&gt;components.json&lt;/code&gt; with correct aliases:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- components.json (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ components.json (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -4,22 +4,16 @@&lt;/span&gt;
   "tsx": true,
   "tailwind": {
     "config": "",
&lt;span class="gd"&gt;-    "css": "src/styles/globals.css",
&lt;/span&gt;&lt;span class="gi"&gt;+    "css": "libs/ui/src/globals.css",
&lt;/span&gt;     "baseColor": "neutral",
     "cssVariables": true,
     "prefix": ""
   },
   "aliases": {
&lt;span class="gd"&gt;-    "components": "@/components",
-    "utils": "@/lib/utils",
-    "ui": "@/components/ui",
-    "lib": "@/lib",
-    "hooks": "@/hooks"
&lt;/span&gt;&lt;span class="gi"&gt;+    "components": "@/libs/ui/src/components",
+    "hooks": "@/libs/ui/src/hooks",
+    "utils": "@my-workspace/utils"
&lt;/span&gt;   },
   "iconLibrary": "lucide"
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add a Shadcn component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx shadcn@latest add button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Move and export the Button component from &lt;code&gt;libs/ui/src/components/ui/button.tsx&lt;/code&gt; to &lt;code&gt;libs/ui/src/components/Button/Button.tsx&lt;/code&gt;. Update &lt;code&gt;libs/ui/src/index.ts&lt;/code&gt; to export it.&lt;/p&gt;

&lt;p&gt;Move &lt;code&gt;lib/utils.ts&lt;/code&gt; to &lt;code&gt;libs/utils/src/dom/cn.ts&lt;/code&gt; and export it from &lt;code&gt;libs/utils/src/index.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Update &lt;code&gt;libs/utils/tsconfig.lib.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- libs/utils/tsconfig.lib.json (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ libs/utils/tsconfig.lib.json (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -8,7 +8,9 @@&lt;/span&gt;
     "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
     "emitDeclarationOnly": true,
     "forceConsistentCasingInFileNames": true,
&lt;span class="gd"&gt;-    "types": ["node"]
&lt;/span&gt;&lt;span class="gi"&gt;+    "types": ["node"],
+    "module": "ESNext",
+    "moduleResolution": "node"
&lt;/span&gt;   },
   "include": ["src/**/*.ts"],
   "references": []
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;libs/ui/package.json&lt;/code&gt;'s main property to &lt;code&gt;./src/index.ts&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Integrate Styles and Components
&lt;/h2&gt;

&lt;p&gt;Update &lt;code&gt;apps/website/src/pages/styles.css&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"../../../../libs/ui/src/globals.css"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@source&lt;/span&gt; &lt;span class="s1"&gt;"../../src/**/*.{ts,tsx,js,jsx}"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@source&lt;/span&gt; &lt;span class="s1"&gt;"../../../../libs/ui/src/**/*.{ts,tsx,js,jsx}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;apps/website/tsconfig.json&lt;/code&gt; with aliases and references:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- apps/website/tsconfig.json (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ apps/website/tsconfig.json (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -21,9 +21,13 @@&lt;/span&gt;
       {
         "name": "next"
       }
     ],    
     "paths": {
       "@/*": [
         "./src/*"
&lt;span class="gi"&gt;+      ],
+      "@my-workspace/ui": [
+        "../../libs/ui"
&lt;/span&gt;       ]
     },
     "outDir": "dist",
&lt;span class="p"&gt;@@ -47,7 +51,10 @@&lt;/span&gt;
     "src/**/*.spec.ts",
     "src/**/*.test.ts",
     ".next"
&lt;span class="gd"&gt;-  ]
&lt;/span&gt;&lt;span class="gi"&gt;+  ],
+  "references": [
+    { "path": "../../libs/ui" }
+  ]    
&lt;/span&gt; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import and use the Button component in &lt;code&gt;apps/website/src/pages/index.tsx&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;cn&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@my-workspace/utils&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@my-workspace/ui&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;cn&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex flex-row&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;items-center justify-center&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-screen w-screen&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bg-gray-900&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;destructive&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello World&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Set Up Storybook
&lt;/h2&gt;

&lt;p&gt;Add the Storybook plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx add @nx/storybook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize Storybook in &lt;code&gt;libs/ui&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx nx g @nx/react:storybook-configuration @my-workspace/ui

✔ Do you want to &lt;span class="nb"&gt;set &lt;/span&gt;up Storybook interaction tests? &lt;span class="o"&gt;(&lt;/span&gt;Y/n&lt;span class="o"&gt;)&lt;/span&gt; · &lt;span class="nb"&gt;false&lt;/span&gt;
✔ Automatically generate &lt;span class="k"&gt;*&lt;/span&gt;.stories.ts files &lt;span class="k"&gt;for &lt;/span&gt;components declared &lt;span class="k"&gt;in &lt;/span&gt;this project? &lt;span class="o"&gt;(&lt;/span&gt;Y/n&lt;span class="o"&gt;)&lt;/span&gt; · &lt;span class="nb"&gt;true&lt;/span&gt;
✔ Configure a static file server &lt;span class="k"&gt;for &lt;/span&gt;the storybook instance? &lt;span class="o"&gt;(&lt;/span&gt;Y/n&lt;span class="o"&gt;)&lt;/span&gt; · &lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install &lt;code&gt;@tailwindcss/vite&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add @tailwindcss/vite
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;libs/ui/vite.config.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- libs/ui/vite.config.js (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ libs/ui/vite.config.js (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -3,6 +3,7 @@&lt;/span&gt;
 import react from "@vitejs/plugin-react";
 import dts from "vite-plugin-dts";
 import * as path from "path";
&lt;span class="gi"&gt;+import tailwindcss from "@tailwindcss/vite";
&lt;/span&gt;&lt;span class="err"&gt;
&lt;/span&gt; export default defineConfig(() =&amp;gt; ({
   root: __dirname,
&lt;span class="p"&gt;@@ -12,7 +13,8 @@&lt;/span&gt;
     dts({
       entryRoot: "src",
       tsconfigPath: path.join(__dirname, "tsconfig.lib.json"),
&lt;span class="gd"&gt;-    })
&lt;/span&gt;&lt;span class="gi"&gt;+    }),
+    tailwindcss(),
&lt;/span&gt;   ],
   // Uncomment this if you are using workers.
   // worker: {
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;libs/ui/.storybook/main.ts&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;--- libs/ui/.storybook/main.ts (old)
&lt;/span&gt;&lt;span class="gi"&gt;+++ libs/ui/.storybook/main.ts (new)
&lt;/span&gt;&lt;span class="p"&gt;@@ -1,7 +1,7 @@&lt;/span&gt;
 import type { StorybookConfig } from "@storybook/react-vite";
&lt;span class="err"&gt;
&lt;/span&gt; const config: StorybookConfig = {
&lt;span class="gd"&gt;-  stories: ["../src/lib/**/*.@(mdx|stories.@(js|jsx|ts|tsx))"],
&lt;/span&gt;&lt;span class="gi"&gt;+  stories: ["../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))"],
&lt;/span&gt;   addons: ["@storybook/addon-essentials"],
   framework: {
     name: "@storybook/react-vite",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create &lt;code&gt;libs/ui/.storybook/styles.css&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"../src/globals.css"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@source&lt;/span&gt; &lt;span class="s1"&gt;"../src/**/*.stories.tsx"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import &lt;code&gt;libs/ui/.storybook/styles.css&lt;/code&gt; in &lt;code&gt;libs/ui/.storybook/preview.ts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create a story in &lt;code&gt;libs/ui/src/components/Button/Button.stories.tsx&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Ensure everything is working as expected by running these commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Launch Storybook for component development&lt;/span&gt;
npx nx storybook ui

&lt;span class="c"&gt;# Start the Next.js development server&lt;/span&gt;
npx nx dev website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Next.js Application&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmkab64q3gja4zrs7urxm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmkab64q3gja4zrs7urxm.png" alt="Next.js app dev mode screenshot" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Storybook&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcl6iif4g4euqnvmtrkyu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcl6iif4g4euqnvmtrkyu.png" alt="Storybook dev mode screenshot" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By following these steps, you've successfully set up an Nx workspace with a Next.js application, a reusable React component library powered by Shadcn UI and Tailwind CSS v4, and a utility library. This robust setup provides a solid foundation for building scalable and maintainable applications.&lt;/p&gt;

&lt;p&gt;The combination of Nx's monorepo capabilities, Next.js's server-side rendering, Shadcn UI's accessible components, and Tailwind CSS v4's utility-first approach allows for rapid development and consistent styling across your projects. Remember to adapt these configurations to your specific project needs and continue exploring the powerful features these tools offer.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>nxworkspace</category>
      <category>shadcn</category>
      <category>react</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
