Vue Installation
Install and configure Nuxt UI in your standalone Vue 3 application with Vite.
Prerequisites
- Node.js
^20.19.0 or >=22.12.0
- Vue
^3.5.0
- Vite-based project setup
Installation
Install the Package
Install Nuxt UI and Tailwind CSS:npm install @nuxt/ui tailwindcss vue-router
vue-router is required for Nuxt UI’s Link component functionality.
Add the Vite Plugin
Add the Nuxt UI Vite plugin to your vite.config.ts:import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui()
]
})
Use the Vue Plugin
Register the Nuxt UI Vue plugin in your main.ts:import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue'
const app = createApp(App)
const router = createRouter({
routes: [],
history: createWebHistory()
})
app.use(router)
app.use(ui)
app.mount('#app')
Import CSS
Import Tailwind CSS and Nuxt UI in your main CSS file:@import "tailwindcss";
@import "@nuxt/ui";
Then import this CSS file in your main.ts:import './assets/main.css'
Plugin Configuration
Customize Nuxt UI by passing options to the Vite plugin:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
// Plugin options
prefix: 'U',
colorMode: true,
theme: {
colors: ['primary', 'secondary', 'success', 'info', 'warning', 'error'],
transitions: true,
defaultVariants: {
color: 'primary',
size: 'md'
}
}
})
]
})
Configuration Options
prefix
Customize the component prefix (default: U).
ui({
prefix: 'UI' // Components will be <UIButton>, <UICard>, etc.
})
colorMode
Enable or disable color mode integration with @vueuse/core (default: true).
ui({
colorMode: false // Disable dark mode support
})
When enabled, Nuxt UI integrates with VueUse’s useDark and useColorMode composables.
theme.colors
Define available color aliases for components (default: ['primary', 'secondary', 'success', 'info', 'warning', 'error']).
ui({
theme: {
colors: ['primary', 'secondary', 'custom']
}
})
theme.transitions
Enable or disable component transitions (default: true).
ui({
theme: {
transitions: false // Disable all transitions
}
})
theme.defaultVariants
Set default variants for all components.
ui({
theme: {
defaultVariants: {
color: 'secondary', // Default color for all components
size: 'lg' // Default size for all components
}
}
})
theme.prefix
Add a prefix to Tailwind CSS utility classes.
ui({
theme: {
prefix: 'tw' // Utility classes become tw:text-center, tw:bg-primary, etc.
}
})
dts
Generate TypeScript declaration files for auto-imported components (default: based on environment).
ui({
dts: true // Always generate .d.ts files
})
router
Configure router integration mode.
ui({
router: true // Use vue-router (default)
})
ui({
router: false // Disable routing, use anchor tags
})
ui({
router: 'inertia' // Use Inertia.js compatibility
})
autoImport
Customize unplugin-auto-import options.
ui({
autoImport: {
imports: [
// Add custom auto-imports
]
}
})
components
Customize unplugin-vue-components options.
ui({
components: {
resolvers: [
// Add custom component resolvers
]
}
})
scanPackages
Scan additional packages for Nuxt UI components.
ui({
scanPackages: ['my-custom-package']
})
Auto-Imports
The Vite plugin automatically imports:
- Components: All UI components are auto-imported with your configured prefix
- Composables: Utility composables from Nuxt UI and VueUse
- Types: TypeScript types for components and composables
Auto-imports are powered by unplugin-auto-import and unplugin-vue-components, which are included with Nuxt UI.
Color Mode Integration
When colorMode: true (default), Nuxt UI integrates with VueUse’s color mode:
<script setup>
import { useDark, useToggle } from '@vueuse/core'
const isDark = useDark()
const toggleDark = useToggle(isDark)
</script>
<template>
<UButton
:icon="isDark ? 'i-heroicons-moon' : 'i-heroicons-sun'"
@click="toggleDark()"
/>
</template>
Inertia.js Integration
For Inertia.js applications, use the router: 'inertia' option:
ui({
router: 'inertia'
})
Then set up Inertia.js normally:
import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import ui from '@nuxt/ui/vue-plugin'
createInertiaApp({
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
return pages[`./Pages/${name}.vue`]
},
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.use(ui)
.mount(el)
},
})
TypeScript Support
For full TypeScript support, ensure your tsconfig.json includes:
{
"compilerOptions": {
"types": [
"@nuxt/ui/vue-plugin"
]
}
}
Next Steps
Component Library
Explore all available components.
Theming
Customize component styles and create your design system.
Composables
Learn about utility composables and hooks.
Examples
See real-world usage examples.