Setting Up TailwindCSS, Shadcn-Vue, and Automatic Component Imports

In this lesson, we'll install and configure Shadcn-Vue and TailwindCSS. We'll then set up automatic imports for all of our local Vue components.

Published
Aug 20, 24
Duration
16m 4s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Get the Code

Download or explore the source code for this lesson on GitHub

Repository

⚠️ Quick Note #1

As of February 20th, 2025, Shadcn-Vue is now running at v1. In this major version change, they've switched from using Radix-UI to Reka-UI as their core library. The installation & configuration process was also changed. To keep your experience consistent with this series, I'd recommend installing & configuring the Radix-UI version of Shadcn-Vue for this series while we compare changes between v0 and v1.

When configuring Shadcn-Vue, please target the Radix-UI version, as shown below.

npx shadcn-vue@radix init
Copied!

Unfortunately, the command to install components has also changed and needs to specify Radix as well. Please use the below when installing components.

npx shadcn-vue@radix add [component-name]
Copied!

⚠️ Quick Note #2

TailwindCSS released v4 on Jan 22nd, 2025 which contains a few breaking changes to the installation process. At this point, many plugins have not yet been updated for v4. For Shadcn-Vue to continue working as intended throughout this series it is recommended, for now, to stick with v3 while following along.

When installing TailwindCSS, please target v3, as shown below.

npm install -D tailwindcss@3 autoprefixer
Copied!

⏳ Chapters

00:00 - Running Our Project
00:50 - Installing Shadcn-Vue & TailwindCSS
04:20 - Configuring Shadcn-Vue
07:50 - Configuring TailwindCSS
09:20 - Installing Our First Shadcn-Vue Component
10:30 - Testing Our Button Component
11:28 - Automatic Component Registration
14:07 - TypeScript Support on Automatically Imported Components

Documentation

VSCode Extension

Shadcn-Vue

Join The Discussion! (14 Comments)

Please sign in or sign up for free to join in on the dicussion.

  1. Commented 2 months ago

    Im following along using SolidJS, but got stuck at the auto imports package as it seems to be a vue specific library - how may i get this working with a SolidJS setup? Thanks!

    1

    Please sign in or sign up for free to reply

    1. Commented 1 month ago

      Hi yunus! Apologies for the delayed response! I'm not familiar with the SolidJS ecosystem in the slightest, so I unfortunately do not know. You might have luck using unplugin-auto-import, that is what unplugin-vue-components utilizes, but I'm not certain whether it'll work nor how it'd need to be configured.

      1

      Please sign in or sign up for free to reply

      1. Commented 1 month ago

        Not a problem brother, appreciate the work you're putting into Adonis :). The potential is huge imo and using Inertia fullstack development just makes sense compared to meta frameworks.
        I decided to stick to React until SolidJS matures a bit more. One other thing i would like to suggest while here is; could we get more information about deployment options using Adonis? Cleavr was looking promising, but i would like to do server management myself on AWS for example(EC2 or ECS/Fargate if possible)

        1

        Please sign in or sign up for free to reply

        1. Commented 1 month ago

          Thank you, yunus! I very much agree in regards to using Inertia over meta frameworks when you need the full stack! 😊

          As for deployment, please see my comment here. The TLDR is it's coming, but not something I do myself all that often. So I just need to dedicate some time to do proper R&D to do some lessons justice. 😁

          0

          Please sign in or sign up for free to reply

  2. Commented 1 month ago

    The Vue ecosystem is fantastic. I’ve also set up Prettier with the following plugins:

    • prettier-plugin-tailwindcss

    • prettier-plugin-organize-attributes

    • prettier-plugin-organize-imports

    This setup ensures consistent code formatting while keeping Tailwind classes, attributes, and imports perfectly organized.

    1

    Please sign in or sign up for free to reply

    1. Commented 1 month ago

      Yeah, I absolutely love Vue & it's ecosystem!! Thank you for sharing these plugins' gribbl!! 😊

      0

      Please sign in or sign up for free to reply

  3. Commented 1 month ago

    @tomgobich I followed your instructions to have the unplugin package to autoimport my shadcn-vue components. It works with simple components like buttons, but more complicated ones, such as resizable needs radix-vue, and I had trouble setting it up the vite.config.js to resolve these more complex components. Do you have nay suggestions?

    1

    Please sign in or sign up for free to reply

    1. Commented 1 month ago

      Hi, csaba-kiss!! You can try registering radix-vue's unplugin-vue-components plugin to see if that helps. The caveat here is you'll likely need to use the original name defined in radix-vue, rather than renamed components from shadcn-vue.

      For example, to auto-import, you'd probably need to use the name "SplitterPanel" rather than shadcn-vue's "ResizablePanel."

      I noticed a similar issue when rebuilding the Adocasts CMS and opted to import the components directly instead.

      import Components from 'unplugin-vue-components/vite'
      import RadixVueResolver from 'radix-vue/resolver'
      
      export default defineConfig({
        plugins: [
          vue(),
          Components({
            dts: true,
            resolvers: [
              RadixVueResolver()
      
              // RadixVueResolver({
              //   prefix: '' // use the prefix option to add Prefix to the imported components
              // })
            ],
          }),
        ],
      })
      Copied!
      0

      Please sign in or sign up for free to reply

  4. Commented 1 month ago

    Tailwindcss 4.0 is released and it does not work out of the box. So to follow this setup, you need to use tailwindcss 3.x.

    1

    Please sign in or sign up for free to reply

    1. Commented 30 days ago

      Yes, thank you very much cinqi! When v4 launched I added a note to the top of this lesson, but failed to realize the plugin Shadcn-Vue uses likely isn't up-to-date with that yet. I've updated my note to recommend sticking to v3 for now when following this series.

      I also have a patch to the video being rendered as we speak, which I should be able to get updated tomorrow.

      1

      Please sign in or sign up for free to reply

  5. Commented 4 days ago

    i am stuck on initializing shadcn-vue
    /var/www $ npx shadcn-vue@latest init

    ✔ Preflight checks.
    ✔ Verifying framework. Found Vite.
    ✖ Validating Tailwind CSS.
    ✖ Validating import alias.
    gives following error:

    No Tailwind CSS configuration found at /var/www.                                                                10:30:30 AM
    It is likely you do not have Tailwind CSS installed or have an invalid configuration.                           10:30:30 AM
    Install Tailwind CSS then try again.
    Copied!
    1

    Please sign in or sign up for free to reply

    1. Commented 4 days ago

      Hi Rajeeb! Apologies about that, it looks like Shadcn-Vue changed their init command to require more manual work to get things set up. Please try initializing using the latest 0 version with:

      npx shadcn-vue@0 init
      Copied!

      I'll have to compare to see what/why they changed it, and I will update this lesson accordingly!

      Edit: Okay, so it looks like in v1 they've switched the default core library from using Radix-Vue to Reka-UI. Using the below to initialize your Shadcn-Vue installation is now the recommended command to continue using Radix, which is what this series uses.

      npx shadcn-vue@radix init
      Copied!

      With this command, this installation should match that covered in this lesson. I'll get this lesson updated accordingly.

      1

      Please sign in or sign up for free to reply

      1. Commented 3 days ago

        Thanks for guidance. Now it worked.

        1

        Please sign in or sign up for free to reply

        1. Commented 3 days ago

          Anytime, Rajeeb! Awesome, great to hear!

          0

          Please sign in or sign up for free to reply