Shadcn Nuxt Module

2.6.2 · active · verified Sun Apr 19

shadcn-nuxt is a Nuxt.js module designed to seamlessly integrate shadcn/ui components (specifically the Vue implementation, shadcn-vue) into Nuxt 3 applications. It automates the setup and configuration process, offering features like automatic import of components into your Nuxt project, abstracting away manual configuration of Tailwind CSS and component paths. The current stable version is 2.6.2, with frequent bug fixes and feature enhancements, indicating an active development cycle. Key differentiators include its robust auto-import mechanism, support for multiple component directories with custom prefixes, and alignment with the upstream shadcn-ui API for consistency. It aims to simplify the developer experience by providing a pre-configured solution for using shadcn-vue's UI library within the Nuxt ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install `shadcn-nuxt` as a Nuxt module and configure it in `nuxt.config.ts`, followed by a basic example of using an auto-imported Shadcn Vue component in an application.

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: [
    'shadcn-nuxt'
  ],
  shadcn: {
    /**
     * Prefix for all the imported component
     */
    prefix: '',
    /**
     * Directory that the component lives in.
     * @default "./components/ui"
     */
    componentDir: './components/ui'
  }
})

// In a Vue component (e.g., app.vue or any page/component file)
<script setup lang="ts">
// Button component is auto-imported by shadcn-nuxt
</script>

<template>
  <div>
    <h1>Welcome to Nuxt with Shadcn Vue!</h1>
    <Button>Click me</Button>
  </div>
</template>

view raw JSON →