<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashutosh Tiwari on Medium]]></title>
        <description><![CDATA[Stories by Ashutosh Tiwari on Medium]]></description>
        <link>https://medium.com/@tiwariashutosh?source=rss-5e77d016fcda------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8kkpwDwt_p3tmkrN3tBVyw.jpeg</url>
            <title>Stories by Ashutosh Tiwari on Medium</title>
            <link>https://medium.com/@tiwariashutosh?source=rss-5e77d016fcda------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 12:17:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tiwariashutosh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build a React UI Library with Shadcn, Vite, Tailwind v4 & Storybook]]></title>
            <link>https://tiwariashutosh.medium.com/how-to-build-a-react-ui-component-library-a-step-by-step-guide-using-shadcn-ui-vite-tailwind-36c1b89e2113?source=rss-5e77d016fcda------2</link>
            <guid isPermaLink="false">https://medium.com/p/36c1b89e2113</guid>
            <category><![CDATA[shadcn]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[storybook]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <dc:creator><![CDATA[Ashutosh Tiwari]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 17:55:22 GMT</pubDate>
            <atom:updated>2026-04-19T06:36:43.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8pWLbFyBwfVU_lYNgzOyA.png" /></figure><p>In this article, we will walk through the process of setting up a React UI component library using Shadcn UI, Vite, Tailwind CSS, and Storybook. But before we dive into the setup process, let’s understand what these technologies are and why we are using them.</p><ul><li><a href="https://ui.shadcn.com/"><strong>Shadcn UI:</strong></a> It is a collection of beautifully designed and accessible components that you can use in your apps. It’s not a traditional component library that you install as a dependency. Instead, you can browse, copy, and paste the components, or customize them to suit your needs. We are using Shadcn UI because it allows us to quickly prototype and build components with a consistent design system.</li><li><a href="https://vitejs.dev/guide/"><strong>Vite</strong></a><strong>:</strong> Vite (French word for “quick”, pronounced /vit/, like “veet”) is a build tool that aims to provide a faster and leaner development experience for modern web projects. It consists of two major parts: A dev server that provides rich feature enhancements over native ES modules, for example extremely fast Hot Module Replacement (HMR), and a build command that bundles your code with Rollup, pre-configured to output highly optimized static assets for production. We are using Vite because it offers a faster and more efficient build process compared to traditional tools.</li><li><a href="https://tailwindcss.com/"><strong>Tailwind CSS</strong></a>: Tailwind CSS is a utility-first CSS framework for rapidly building custom user interfaces. It provides low-level utility classes that let you build completely custom designs without ever leaving your HTML. It does not provide a series of predefined classes for elements such as buttons or tables. We are using Tailwind CSS because it gives us the flexibility to create custom styles easily and efficiently.</li><li><a href="https://storybook.js.org/"><strong>Storybook</strong></a>: Storybook is a tool for building UI components and pages in isolation. It helps you develop and share hard-to-reach states and edge cases without needing to run your whole app. Thousands of teams use it for UI development, testing, and documentation. We are using Storybook because it allows us to develop and test our components in isolation, making the development process more efficient and manageable.</li></ul><p>Now that we have a better understanding of these technologies, let’s dive into the setup process.</p><h3>Prerequisites</h3><p>Before we start, I assume you already know the following:</p><ul><li>React</li><li>TypeScript</li><li>Tailwind CSS</li></ul><p>And make sure you have the following installed on your system:</p><ul><li><strong>Node.js</strong> and <strong>npm</strong></li></ul><h3>Step 1: Setting up the Project with Vite</h3><p>First, we need to set up a new project using Vite (6.3.5). Run the following command in your terminal:</p><pre>npm create vite@latest</pre><p>Follow the on-screen prompts in the terminal and give your project name. For the purpose of this article we are using the name <strong>“aether-ui”</strong>. Since we will be using React and TypeScript, select the options accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikFAHaodGD7_6iKuV4MghQ.png" /></figure><p>After following all the instructions, you should be inside the <strong>aether-ui</strong> project directory and be able to see the Vite demo page at <a href="http://localhost:5173/">http://localhost:5173/</a>.</p><h3>Step 2: Installing Tailwind CSS</h3><p>Next, we install Tailwind CSS (4.1.6) using the following command:</p><pre>npm install tailwindcss @tailwindcss/vite</pre><h3>Step 3: Configuring Tailwind CSS</h3><p>After installing Tailwind, we need to configure some of our files to complete the setup.</p><p>First, we need to add the tailwind plugin to our vite configuration file so that it is detected correctly. For this, import and add the tailwindcss() plugin from the @tailwindcss/vite package that we installed, to your vite.config.ts file. Your file should now look something like this:</p><pre>//vite.config.ts<br><br>import { defineConfig } from &#39;vite&#39;<br>import react from &#39;@vitejs/plugin-react-swc&#39;<br>import tailwindcss from &#39;@tailwindcss/vite&#39;<br><br>// https://vite.dev/config/<br>export default defineConfig({<br>  plugins: [react()],<br>  plugins: [react(), tailwindcss()],<br>})</pre><p>Remove everything from the global CSS file src/index.css and import tailwind CSS:</p><pre>@import &quot;tailwindcss&quot;;</pre><p>Replace everything in your App.tsx file with the following and run npm run dev:</p><pre>export default function App() {<br>  return (<br>    &lt;div className=&#39;min-h-screen bg-gray-100 flex flex-col items-center justify-center p-4 gap-6&#39;&gt;<br>      &lt;h1 className=&#39;text-3xl font-bold text-gray-800&#39;&gt;UI Library Demo&lt;/h1&gt;<br>    &lt;/div&gt;<br>  )<br>}</pre><p>You should see the following in the browser at <a href="http://localhost:5173/">http://localhost:5173/</a> now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQ08cQzMPNslzn-qd2a8Mw.png" /></figure><p>At this point, we have a project with Vite and Tailwind installed.</p><h3>Step 4: Integrating Storybook</h3><p>Now we will be integrating Storybook 8 to develop our UI components in isolation and provide a clean documentation for each of those components. Install it using the following command:</p><pre>npm create storybook@latest</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D_SUftMDExUWPeJm.png" /></figure><p>For Tailwind classes to work with Storybook, we need to import our global CSS in the .storybook/preview.ts file:</p><pre>import &#39;../src/index.css&#39;</pre><p>I also removed some unwanted storybook related boilerplate code, which you can check in my repo (link at the end of the article) and compare accordingly.</p><h3>Step 5: Installing Shadcn UI</h3><p>Now we will be setting up Shadcn in our project, using which we will be creating our UI components.</p><p>Firstly, we need to add some code in compilerOptions of our tsconfig.json and tsconfig.app.jsonfile to resolve paths:</p><pre>//tsconfig.json<br><br>{<br>  &quot;files&quot;: [],<br>  &quot;references&quot;: [<br>    {<br>      &quot;path&quot;: &quot;./tsconfig.app.json&quot;<br>    },<br>    {<br>      &quot;path&quot;: &quot;./tsconfig.node.json&quot;<br>    }<br>  ],<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;@/*&quot;: [&quot;./src/*&quot;]<br>    }<br>  }<br>}</pre><pre>//tsconfig.app.json<br><br>{<br>  &quot;compilerOptions&quot;: {<br>    // ...<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;@/*&quot;: [<br>        &quot;./src/*&quot;<br>      ]<br>    }<br>    // ...<br>  }<br>}</pre><p>Then we will install @types/node using the following command:</p><pre># (so you can import &quot;path&quot; without error)<br>npm install -D @types/node</pre><p>We’ll add a line to the vite.config.ts file, so your app can resolve src paths with the alias @ without any errors, and now your file should look like this:</p><pre>import { defineConfig } from &#39;vite&#39;<br>import react from &#39;@vitejs/plugin-react-swc&#39;<br>import tailwindcss from &#39;@tailwindcss/vite&#39;<br>import path from &#39;path&#39;<br><br>// https://vite.dev/config/<br>export default defineConfig({<br>  plugins: [react(), tailwindcss()],<br>  resolve: {<br>    alias: {<br>      &#39;@&#39;: path.resolve(__dirname, &#39;./src&#39;),<br>    },<br>  },<br>})</pre><p>Run the shadcn-ui init command to setup your project:</p><pre>npx shadcn@latest init</pre><p>Choose the base color as per your wish, and the rest will be configured automatically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GNSIDKI_OLnvaMqW16TpxA.png" /></figure><blockquote>Please note that at the time of updating this article (May 14, 2025), <strong>shadcn </strong>does not fully support React 19 completely in the stable release, hence the warning in the screenshot above. React 19 support is added in the canary release.</blockquote><p>Now we are ready to add our first component.</p><h3>Step 6: Creating a Component</h3><p>Now, let’s create a simple component using Shadcn UI. The command below will add the Button component to your project:</p><pre>npx shadcn@latest add button</pre><p>You can now import the Button component in your Storybook story or edit the component at src\components\ui\button.tsx</p><h3>Step 7: Adding Component to Storybook</h3><p>Finally, let’s add our Button component to Storybook. There will be an existing Button component created by Storybook, we can delete it along with other sample components. Edit file Button.stories.tsx in the src\stories\Button.stories.ts directory as follows:</p><pre>import type { Meta, StoryObj } from &#39;@storybook/react&#39;<br><br>import { Button } from &#39;../components/ui/button&#39;<br><br>const meta: Meta&lt;typeof Button&gt; = {<br>  component: Button,<br>  title: &#39;Components/Button&#39;,<br>  parameters: {<br>    layout: &#39;centered&#39;,<br>  },<br>}<br>export default meta<br><br>type Story = StoryObj&lt;typeof Button&gt;<br><br>export const Default: Story = {<br>  args: {<br>    children: &#39;Click Me&#39;,<br>    variant: &#39;default&#39;,<br>  },<br>}<br><br>export const Outline: Story = {<br>  args: {<br>    children: &#39;Click Me&#39;,<br>    variant: &#39;outline&#39;,<br>  },<br>}</pre><p>Now, you can run npm run storybook to start Storybook, and see your component in action at <a href="http://localhost:6006/">http://localhost:6006/</a>. It should look something like this, with two variants:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOUX3aF2jLF5s-6y73gp6g.png" /></figure><p>You can now go ahead and customize your Button component and add more shadcn components from <a href="https://ui.shadcn.com/docs/components">here</a>.</p><p><a href="https://github.com/iashutoshtiwari/aether-ui.git">Here</a> is the link to the GitHub repository of above code which you can use for reference or template.</p><h3>Conclusion</h3><p>Congratulations! You’ve just set up a React UI component library using Shadcn UI, Vite, Tailwind CSS, and Storybook. This setup will help you create and manage your components efficiently.</p><p>Do give a like if it helped you and feel free to reach out in the comments if you face any errors.</p><p><strong>You can also read this article on my personal website </strong><a href="https://ashutoshtiwari.dev/blog/ui-library-with-shadcn-vite-tailwind-and-storybook"><strong>here</strong></a><strong>.</strong></p><p>Follow me for more such guides and discussions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36c1b89e2113" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>