# Nuxt UI Reference **Last Updated:** 2025-11 (v4.1.0) **Check:** `@nuxt/ui` in package.json Nuxt UI is a component library built on Tailwind CSS that provides pre-built, accessible UI components for Nuxt applications. ## Version Detection Check `package.json` to determine which version is installed: - **v4.x** - Latest version (Nuxt 4 required, Tailwind v4, breaking changes from v3) - **v3.x** - Previous stable (Nuxt 3, Tailwind v3) - **v2.x** - Legacy version (deprecated) For v4-specific features and migration, always verify with official docs: https://ui.nuxt.com ## Installation & Setup ### v4 Setup (Current) **Prerequisites:** - Nuxt 4+ - Tailwind CSS v4 ```bash pnpm add @nuxt/ui ``` **Required Configuration:** 1. **nuxt.config.ts:** ```typescript export default defineNuxtConfig({ modules: ["@nuxt/ui"], // Optional: Configure color theme colorMode: { preference: "system", // 'light' | 'dark' | 'system' }, }) ``` 2. **app.vue - UApp Wrapper (Required):** ```vue ``` 3. **assets/css/main.css - Tailwind v4 Import:** ```css @import "tailwindcss"; ``` 4. **app.config.ts - Color Configuration:** ```typescript export default defineAppConfig({ ui: { colors: { primary: "blue", neutral: "slate", }, }, }) ``` ### v3 Setup (Previous Version) ```bash pnpm add @nuxt/ui ``` ```typescript // nuxt.config.ts export default defineNuxtConfig({ modules: ["@nuxt/ui"], }) ``` ```css /* assets/css/main.css */ @tailwind base; @tailwind components; @tailwind utilities; ``` ## Breaking Changes ### v3 → v4 Migration **Component Renames:** - `UButtonGroup` → `UFieldGroup` - `UFormGroup` → `UFieldGroup` - `UVerticalNavigation` → `UNavigationTree` **Modal/Popover/Slideover Structure Changes:** Major structural changes - trigger button now goes inside component, content uses `#content` slot: ```vue Open Content Open Title Content Footer ``` **Composable Changes:** - `useModal()` → `useOverlay()` - Overlays now close automatically on close events (no manual `.close()` needed) **Color System:** Configure colors in `app.config.ts` instead of component props: ```typescript // app.config.ts (v4) export default defineAppConfig({ ui: { colors: { primary: "blue", // Changed from 'primary' prop on components neutral: "slate", }, }, }) ``` **Tailwind v4 Requirement:** - Must use `@import "tailwindcss"` in main.css - Tailwind config now uses CSS-based configuration For complete migration details, always check: https://ui.nuxt.com/getting-started/migration ### v2 → v3 Migration Major overhaul with many breaking changes. Recommend checking official migration guide for projects still on v2. ## Common Components ### Forms #### UInput ```vue ``` #### UTextarea ```vue ``` #### USelect ```vue ``` #### UCheckbox & URadio ```vue ``` #### UFieldGroup (v4) / UFormGroup (v3) ```vue ``` ### Buttons #### UButton ```vue Primary Button Outline Ghost Add Loading... Disabled ``` #### UButtonGroup (v3) / UFieldGroup (v4) ```vue One Two Three One Two Three ``` ### Overlays #### UModal ```vue Open Modal Modal Title Modal content goes here... Cancel Submit Open Modal Modal Title Modal content goes here... Cancel Submit ``` #### UPopover ```vue Open Popover Popover content Open Popover Popover content ``` #### UTooltip ```vue ``` ### Navigation #### ULink ```vue About Us External Link Settings ``` #### UTabs ```vue Account settings content Security settings content ``` #### UBreadcrumb ```vue ``` ### Data Display #### UCard ```vue Card Title Card body content goes here. Action ``` #### UTable ```vue {{ row.name }} Edit ``` #### UBadge ```vue Default Subtle Small ``` #### UAlert ```vue ``` ### Feedback #### UNotification (Toast) ```vue Show Toast ``` #### UProgress ```vue Increase ``` ## Form Validation ### Using with Zod (Recommended) ```vue Submit ``` ## Theming & Customization ### Color Configuration (v4) ```typescript // app.config.ts export default defineAppConfig({ ui: { colors: { primary: "blue", secondary: "purple", success: "green", warning: "yellow", error: "red", neutral: "slate", }, }, }) ``` ### Component Styling Override component styles using Tailwind classes: ```vue Custom Styled Button ``` ### Dark Mode Nuxt UI automatically supports dark mode when `@nuxtjs/color-mode` is configured: ```vue This card adapts to light/dark mode Toggle Dark Mode ``` ## Nuxt UI-Specific Tailwind Configuration When using Nuxt UI v4 with Tailwind v4, the Tailwind setup is automatically configured by the module. However, you may need custom configuration: ### Custom Tailwind Classes with Nuxt UI ```css /* assets/css/main.css */ @import "tailwindcss"; /* Custom utilities that work with Nuxt UI */ @layer utilities { .text-gradient { @apply bg-gradient-to-r from-blue-500 to-purple-500 bg-clip-text text-transparent; } } ``` ### Extending Nuxt UI Colors ```typescript // tailwind.config.ts import type { Config } from "tailwindcss" export default { theme: { extend: { colors: { // Add custom colors that integrate with Nuxt UI brand: { 50: "#f0f9ff", 100: "#e0f2fe", // ... more shades 900: "#0c4a6e", }, }, }, }, } satisfies Config ``` Reference `app.config.ts` to use custom color in Nuxt UI: ```typescript // app.config.ts export default defineAppConfig({ ui: { colors: { primary: "brand", // Use custom Tailwind color }, }, }) ``` ## Common Patterns ### Loading States ```vue Submit ``` ### Confirmation Dialogs ```vue Delete Confirm Deletion Are you sure you want to delete this item? Cancel Delete ``` ### Data Tables with Actions ```vue ``` ## Icons Nuxt UI v4 uses Iconify with the `i-` prefix: ```vue Home GitHub Twitter ``` Browse icons at: https://icones.js.org ## Best Practices 1. **Always wrap app with UApp (v4)** - Required for proper functioning 2. **Use v-model:open for modals** (v4) - Breaking change from v3 3. **Configure colors in app.config.ts** (v4) - Centralized theming 4. **Check package.json version** - Use version-appropriate syntax 5. **Leverage auto-completion** - TypeScript types are fully supported 6. **Use built-in validation** - Integrate with Zod for form validation 7. **Prefer composition** - Use slots and composables over prop overload 8. **Follow Tailwind patterns** - Nuxt UI components accept Tailwind classes 9. **Test dark mode** - Always verify components in both light and dark modes ## Troubleshooting ### Common Issues (v4) **Missing UApp wrapper:** ``` Error: Nuxt UI components require wrapper ``` Solution: Wrap your app in `app.vue`: ```vue ``` **Tailwind not working:** Ensure `main.css` has: ```css @import "tailwindcss"; ``` **v-model not working on Modal:** Use `v-model:open` instead of `v-model` in v4. ## Migration Checklist When upgrading from v3 to v4: - [ ] Upgrade to Nuxt 4 - [ ] Install Tailwind CSS v4 - [ ] Update `main.css` to use `@import "tailwindcss"` - [ ] Wrap app with `` in `app.vue` - [ ] Move color config to `app.config.ts` - [ ] Update `v-model` to `v-model:open` on Modal/Popover/Dialog - [ ] Rename `UButtonGroup` → `UFieldGroup` - [ ] Rename `UFormGroup` → `UFieldGroup` - [ ] Rename `UVerticalNavigation` → `UNavigationTree` - [ ] Test all components in both light and dark mode - [ ] Review official migration guide for additional breaking changes ## Official Resources - **Documentation:** https://ui.nuxt.com - **Migration Guide:** https://ui.nuxt.com/getting-started/migration - **Component Reference:** https://ui.nuxt.com/components - **GitHub:** https://github.com/nuxt/ui - **Iconify Icons:** https://icones.js.org --- **Note:** Always verify version-specific syntax with official documentation at https://ui.nuxt.com. This reference covers v3 and v4, but breaking changes may occur in future releases.
Modal content goes here...
Popover content
Card body content goes here.
This card adapts to light/dark mode
Are you sure you want to delete this item?