설치
설치 (Installation)
Nuxt UI를 Vue 애플리케이션에 설치하고 설정하는 방법을 다루는 가이드예요. 순수 Vite와 Inertia 환경 모두를 지원합니다.
출처: Nuxt UI
본문
Vue 애플리케이션에 Nuxt UI를 설치하고 설정하는 방법을 배워 보세요. 순수 Vite와 Inertia 환경 모두와 호환됩니다.
[!NOTE] See: /docs/getting-started/installation/nuxt
Nuxt 버전을 찾고 계신가요?
설정 (Setup)
Vue 프로젝트에 추가하기
Nuxt UI 패키지 설치
pnpm add @nuxt/ui tailwindcss
yarn add @nuxt/ui tailwindcss
npm install @nuxt/ui tailwindcss
bun add @nuxt/ui tailwindcss
vite.config.ts에 Nuxt UI Vite 플러그인 추가
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui()
]
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
import laravel from 'laravel-vite-plugin'
export default defineConfig({
plugins: [
laravel({
input: ['resources/js/app.ts'],
refresh: true
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false
}
}
}),
ui({
router: 'inertia'
})
]
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
import adonisjs from '@adonisjs/vite/client'
import inertia from '@adonisjs/inertia/client'
export default defineConfig({
plugins: [
adonisjs({
entrypoints: ['inertia/app/app.ts'],
reload: ['resources/views/**/*.edge']
}),
inertia(),
vue(),
ui({
router: 'inertia'
})
]
})
[!TIP]
Nuxt UI는
unplugin-auto-import와unplugin-vue-components를 등록하며, 이들이auto-imports.d.ts와components.d.ts타입 선언 파일을 생성해요. 보통 이 파일들은 gitignore 하고tsconfig에 추가하게 됩니다.{ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "auto-imports.d.ts", "components.d.ts"] }# Auto-generated type declarations auto-imports.d.ts components.d.ts
[!WARNING]
이 선언 파일들은 Vite가 실행될 때만 생성됩니다. 기본
create-vue의build스크립트는vue-tsc를vite build와 병렬로 실행하므로(run-p type-check "build-only {@}"), 깨끗한 체크아웃에서는 파일이 존재하기 전에 타입 체크가 시작되어Cannot find name 'useToast'같은 오류가 날 수 있어요. 선언 파일이 먼저 생성되도록 빌드 후 타입 체크를 실행하는 게 좋습니다.{ "scripts": { "build": "run-s build-only type-check" } }
[!TIP]
내부적으로 Nuxt UI는 테마 타입을 resolve 하기 위해 커스텀 별칭(alias)에 의존해요. TypeScript를 쓴다면
vite.config.ts에서 자동 완성을 위해 이 별칭들을tsconfig에 추가하세요.{ "compilerOptions": { "paths": { "#build/ui": [ "./node_modules/.nuxt-ui/ui" ] } } }{ "compilerOptions": { "paths": { "#build/ui/*": [ "./node_modules/.nuxt-ui/ui/*" ] } } }
Nuxt UI Vue 플러그인 사용
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 type { DefineComponent } from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import ui from '@nuxt/ui/vue-plugin'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
import { createApp, h } from 'vue'
const appName = import.meta.env.VITE_APP_NAME || 'Laravel x Nuxt UI'
createInertiaApp({
title: title => (title ? `${title} - ${appName}` : appName),
resolve: name =>
resolvePageComponent(
`./pages/${name}.vue`,
import.meta.glob<DefineComponent>('./pages/**/*.vue')
),
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.use(ui)
.mount(el)
}
})
import type { DefineComponent } from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import ui from '@nuxt/ui/vue-plugin'
import { resolvePageComponent } from '@adonisjs/inertia/helpers'
import { createApp, h } from 'vue'
const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS x Nuxt UI'
createInertiaApp({
title: title => (title ? `${title} - ${appName}` : appName),
resolve: name =>
resolvePageComponent(
`../pages/${name}.vue`,
import.meta.glob<DefineComponent>('../pages/**/*.vue')
),
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.use(ui)
.mount(el)
}
})
CSS에서 Tailwind CSS와 Nuxt UI 임포트
@import "tailwindcss";
@import "@nuxt/ui";
@import "tailwindcss";
@import "@nuxt/ui";
@import "tailwindcss";
@import "@nuxt/ui";
[!TIP]
엔트리포인트에서 CSS 파일을 임포트하세요.
import './assets/css/main.css' 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/app.css' import type { DefineComponent } from 'vue' import { createInertiaApp } from '@inertiajs/vue3' import ui from '@nuxt/ui/vue-plugin' import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers' import { createApp, h } from 'vue' const appName = import.meta.env.VITE_APP_NAME || 'Laravel x Nuxt UI' createInertiaApp({ title: title => (title ? `${title} - ${appName}` : appName), resolve: name => resolvePageComponent( `./pages/${name}.vue`, import.meta.glob<DefineComponent>('./pages/**/*.vue') ), setup({ el, App, props, plugin }) { createApp({ render: () => h(App, props) }) .use(plugin) .use(ui) .mount(el) } })import '../css/app.css' import type { DefineComponent } from 'vue' import { createInertiaApp } from '@inertiajs/vue3' import ui from '@nuxt/ui/vue-plugin' import { resolvePageComponent } from '@adonisjs/inertia/helpers' import { createApp, h } from 'vue' const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS x Nuxt UI' createInertiaApp({ title: title => (title ? `${title} - ${appName}` : appName), resolve: name => resolvePageComponent( `../pages/${name}.vue`, import.meta.glob<DefineComponent>('../pages/**/*.vue') ), setup({ el, App, props, plugin }) { createApp({ render: () => h(App, props) }) .use(plugin) .use(ui) .mount(el) } })
[!NOTE]
VSCode용 Tailwind CSS IntelliSense 확장을 설치하고 다음 설정을 추가하는 것을 권장해요:
{ "files.associations": { "*.css": "tailwindcss" }, "editor.quickSuggestions": { "strings": "on" }, "tailwindCSS.classAttributes": ["class", "ui"], "tailwindCSS.classFunctions": ["defineAppConfig"] }
App 컴포넌트로 감싸기
<template>
<UApp>
<RouterView />
</UApp>
</template>
<template>
<UApp>
<!-- Your content goes here -->
</UApp>
</template>
<template>
<UApp>
<!-- Your content goes here -->
</UApp>
</template>
[!NOTE] See: /docs/components/app
App컴포넌트는 전역 설정을 구성하며 Toast, Tooltip, 프로그래매틱 오버레이에 필수적이에요.
루트 컨테이너에 isolate 클래스 추가
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Nuxt UI</title>
</head>
<body>
<div id="app" class="isolate"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
@inertiaHead
@vite('resources/js/app.ts')
</head>
<body>
<div class="isolate">
@inertia
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
@inertiaHead()
@vite(['inertia/app/app.ts', `inertia/pages/${page.component}.vue`])
</head>
<body>
@inertia({ class: 'isolate' })
</body>
</html>
[!NOTE]
이렇게 하면 스타일이 앱에만 적용되고 오버레이와 스태킹 컨텍스트 관련 문제를 방지할 수 있어요.
Vue 템플릿 사용하기
GitHub의 Use this template 버튼이나 CLI를 사용해 공식 템플릿 중 하나로 시작할 수 있어요:
npm create nuxt@latest -- --no-modules -t ui-vue
npm create nuxt@latest -- --no-modules -t ui-vue/dashboard
npm create nuxt@latest -- --no-modules -t ui-vue/chat
Nuxt UI를 시작하기 위한 최소한의 템플릿이에요.
정교한 관리자 인터페이스를 만들기 위한 다중 컬럼 레이아웃의 대시보드 템플릿이에요.
Vercel AI SDK로 구동되는 나만의 챗봇을 만들 수 있는 AI 챗봇 템플릿이에요.
Inertia.js를 사용하는 AdonisJS용 최소 Nuxt UI 템플릿이에요.
Inertia.js를 사용하는 Laravel용 최소 Nuxt UI 템플릿이에요.
옵션 (Options)
vite.config.ts에서 옵션을 제공해 Nuxt UI를 커스터마이즈할 수 있어요.
prefix
prefix 옵션을 사용하면 컴포넌트의 접두사를 바꿀 수 있어요.
- 기본값:
U
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
prefix: 'Nuxt'
})
]
})
ui
ui 옵션을 사용하면 Nuxt UI에 대한 설정을 제공할 수 있어요. 이는 Nuxt의 app.config.ts에 있는 ui 키의 Vue 버전입니다.
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
colors: {
primary: 'green',
neutral: 'slate'
}
}
})
]
})
dts
dts 옵션을 사용하면 자동 임포트되는 컴포넌트와 컴포저블의 선언 파일 생성을 켜거나 끌 수 있어요.
- 기본값:
true
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
dts: false
})
]
})
icon
icon 옵션을 사용하면 Icon 컴포넌트의 기본 props(size, mode, customize)를 설정하고 clientBundle을 통해 빌드 타임 아이콘 번들링을 구성할 수 있어요. Nuxt UI 자체 아이콘의 번들링은 해당 컬렉션이 설치되어 있을 때 기본으로 활성화됩니다. clientBundle: false로 설정하면 선택하지 않을 수 있어요.
- 기본값:
{}
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
icon: {
mode: 'svg',
clientBundle: {
scan: true
}
}
})
]
})
[!NOTE] See: /docs/getting-started/integrations/icons/vue#collections
아이콘 컬렉션과 클라이언트 번들링에 대해 더 자세히 알고 싶다면 Icons 문서를 확인하세요.
colorMode
colorMode 옵션을 사용하면 @vueuse/core의 컬러 모드 통합을 켜거나 끌 수 있어요.
- 기본값:
true
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
colorMode: false
})
]
})
theme.colors
theme.colors 옵션을 사용하면 컴포넌트 테마를 생성하는 데 사용되는 동적 색상 별칭을 정의할 수 있어요.
- 기본값:
['primary', 'secondary', 'success', 'info', 'warning', 'error']
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
theme: {
colors: ['primary', 'error']
}
})
]
})
[!NOTE]
각 별칭은 앱에서 사용 여부와 관계없이 색상 변형이 있는 컴포넌트 테마에
--ui-color-*쉐이드와 변형의 전체 세트를 생성해요. 실제로 사용하는 별칭만 남기고, 폼을 쓰면 검증 스타일이 필요한error는 유지하세요.
[!TIP] See: /docs/getting-started/theme/design-system#color-system
색상 커스터마이즈와 테마 설정에 대해 더 자세히 알고 싶다면 Theme 섹션을 확인하세요.
theme.transitions
theme.transitions 옵션을 사용하면 컴포넌트의 트랜지션을 켜거나 끌 수 있어요.
- 기본값:
true
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
theme: {
transitions: false
}
})
]
})
[!NOTE]
이 옵션은 hover나 active 상태가 있는 컴포넌트에
transition-colors클래스를 추가해요.
theme.unstyled 4.9+
theme.unstyled 옵션을 사용하면 컴포넌트에서 모든 기본 테마 클래스를 제거할 수 있어요. 구조와 class, ui, app.config.ui로 제공한 클래스만 남깁니다.
- 기본값:
false
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
theme: {
unstyled: true
}
})
]
})
[!WARNING]
이 옵션은 꾸미기용 클래스만이 아니라 구조적 클래스(위치 지정, 트랜지션, flex/grid)도 제거해요.
Modal,Drawer,Calendar같은 레이아웃 중심 컴포넌트는 PrimeVue의 unstyled 모드처럼 레이아웃을 다시 제공해 줘야 합니다.
theme.defaultVariants
theme.defaultVariants 옵션을 사용하면 컴포넌트의 기본 color와 size 변형을 재정의할 수 있어요.
정확히 primary 또는 md인 기본값만 대체되므로, Avatar는 color: 'neutral'을, Separator는 size: 'xs'를 유지합니다.
- 기본값:
{ color: 'primary', size: 'md' }
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
theme: {
defaultVariants: {
color: 'neutral',
size: 'sm'
}
}
})
]
})
theme.prefix 4.2+
theme.prefix 옵션을 사용하면 Tailwind CSS 임포트에 설정한 것과 동일한 접두사를 구성할 수 있어요. 이렇게 하면 Nuxt UI 컴포넌트가 올바른 접두사 유틸리티 클래스와 CSS 변수를 사용하게 됩니다.
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
theme: {
prefix: 'tw'
}
})
]
})
@import "tailwindcss" prefix(tw);
@import "@nuxt/ui";
이것은 Nuxt UI 컴포넌트 테마의 모든 Tailwind 유틸리티 클래스와 CSS 변수에 자동으로 접두사를 붙입니다:
<!-- Without prefix -->
<button class="px-2 py-1 text-xs hover:bg-primary/75">Button</button>
<!-- With prefix: tw -->
<button class="tw:px-2 tw:py-1 tw:text-xs tw:hover:bg-primary/75">Button</button>
[!NOTE] See: https://tailwindcss.com/docs/styling-with-utility-classes#using-the-prefix-option
Tailwind CSS 문서에서 접두사 사용에 대해 더 자세히 알아보세요.
prose
prose 옵션을 사용하면 Nuxt UI Prose 컴포넌트와 그 테마를 활성화할 수 있어요.
- 기본값:
false
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
prose: true
})
]
})
autoImport
autoImport 옵션을 사용하면 컴포저블 자동 임포트를 끄거나 unplugin-auto-import 옵션을 커스터마이즈할 수 있어요.
- 기본값:
{}
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
autoImport: false
})
]
})
[!NOTE]
비활성화하면
@nuxt/ui/composables에서 컴포저블을 명시적으로 임포트할 수 있습니다.
components
components 옵션을 사용하면 컴포넌트 자동 임포트를 끄거나 unplugin-vue-components 옵션을 커스터마이즈할 수 있어요.
- 기본값:
{}
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
components: false
})
]
})
[!NOTE]
비활성화하면 컴포넌트를 명시적으로 임포트할 수 있어요. 예:
import Button from '@nuxt/ui/components/Button.vue'또는import ProseCode from '@nuxt/ui/components/prose/Code.vue'.
router 4.3+
router 옵션을 사용하면 라우팅 통합을 구성할 수 있어요. vue-router를 사용하지 않는 앱(Electron 앱, MPA, Inertia.js나 Hybridly 같은 프레임워크)에 유용합니다.
- 기본값:
true
| 값 | 설명 |
|---|---|
true |
RouterLink 컴포넌트로 네비게이션에 vue-router를 사용해요. |
false |
라우팅 통합을 비활성화하고, 링크를 일반 <a> 태그로 렌더링해요. |
'inertia' |
Link 컴포넌트로 네비게이션에 Inertia.js를 사용해요. |
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
router: false
})
]
})
[!TIP]
Hybridly 같은 프레임워크에 커스텀 네비게이션 로직을 제공하려면 Vite 설정에서
router: false로 설정하고 Vue 플러그인을 설치할 때 함수를 전달하면 됩니다:import ui from '@nuxt/ui/vue-plugin' import { router } from 'hybridly' app.use(ui, { router: (event, { href, external }) => { if (external) { return } event.preventDefault() router.navigate({ url: href }) } })
[!NOTE]
false나'inertia'로 설정하면vue-router는 의존성으로 필요하지 않아요.
scanPackages 4.3+
scanPackages 옵션을 사용하면 Nuxt UI를 사용하는 컴포넌트를 스캔해야 하는 추가 npm 패키지를 지정할 수 있어요. 내부적으로 Nuxt UI 컴포넌트를 사용하는 공유 컴포넌트 라이브러리가 있을 때 유용합니다.
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
scanPackages: ['@my-org/ui-components']
})
]
})
[!NOTE]
기본적으로
@nuxt/ui만 스캔됩니다. 외부 패키지에 Nuxt UI를 사용하는 Vue 컴포넌트가 있으면 이 옵션을 사용하세요.
root 4.9+
root 옵션을 사용하면 Nuxt UI가 .nuxt-ui 디렉터리(테마 템플릿을 담는)를 생성하는 디렉터리를 재정의할 수 있어요. 기본적으로 Vite의 root를 사용하지만, electron-vite 같은 설정에서는 renderer의 root가 하위 디렉터리(예: src/renderer)를 가리켜 템플릿이 Tailwind가 스캔하지 않는 src/renderer/node_modules/.nuxt-ui에 떨어져 bg-default, ring-default, divide-default 같은 테마 클래스가 사리지는 문제가 생깁니다.
import { defineConfig } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
renderer: {
root: 'src/renderer',
plugins: [
vue(),
ui({
root: __dirname
})
]
}
})
[!NOTE]
생성된
.nuxt-ui디렉터리가 Tailwind가 스캔하는node_modules에 들어가도록root를 프로젝트 루트로 지정하세요.
experimental.componentDetection 4.11+
experimental.componentDetection 옵션을 사용하면 트리쉐이킹을 위한 자동 컴포넌트 감지를 활성화할 수 있어요. 이 기능은 소스 코드를 스캔해 실제로 사용되는 컴포넌트를 감지하고 해당 컴포넌트(의존성 포함)에 필요한 CSS만 생성합니다. 사용하지 않으면 Vite 플러그인이 모든 컴포넌트의 테마 CSS를 생성해요. 감지는 Vite root, scanPackages에 나열된 패키지, root 밖에 있는 components 옵션의 dirs를 포함합니다.
- 기본값:
false - 타입:
boolean | string[]
자동 감지 활성화:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
experimental: {
componentDetection: true
}
})
]
})
동적 사용을 위한 추가 컴포넌트 포함:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
experimental: {
componentDetection: ['Modal', 'DropdownMenu', 'Popover']
}
})
]
})
[!NOTE]
컴포넌트 이름 배열을 제공하면 자동 감지가 활성화되고 이 컴포넌트들(의존성 포함)이 반드시 포함됩니다. 정적으로 분석할 수 없는
<component :is="..." />같은 동적 컴포넌트에 유용해요.
[!WARNING]
새로 사용된 컴포넌트는 다음 dev-server 시작 시 감지됩니다. 컴포넌트를 추가했는데 스타일이 빠졌다면 dev 서버를 재시작하세요.
지속적 릴리스 (Continuous releases)
Nuxt UI는 지속적 프리뷰 릴리스를 위해 pkg.pr.new를 사용해요. 공식 릴리스를 기다리지 않고 개발자에게 최신 기능과 버그 수정에 즉시 접근하게 해줍니다.
v4 브랜치의 모든 커밋과 PR에 대해 자동 프리뷰 릴리스가 생성됩니다. 패키지 버전을 특정 커밋 해시나 PR 번호로 바꿔서 사용하세요.
{
"dependencies": {
- "@nuxt/ui": "^4.0.0",
+ "@nuxt/ui": "https://pkg.pr.new/@nuxt/ui@4c96909",
}
}
[!NOTE]
pkg.pr.new는 설치 URL을 PR에 자동으로 댓글로 남겨 변경 사항을 쉽게 테스트할 수 있게 합니다.