디자인 시스템
디자인 시스템 (Design System)
Nuxt UI의 디자인 시스템은 Tailwind CSS를 기반으로 하여 간단한 테마 적용과 손쉬운 커스터마이즈를 지원해요. CSS 우선 방식으로 디자인 토큰을 직접 정의할 수 있어 테마를 이식하고 유지보수하기 쉽게 만들어 줍니다.
출처: Nuxt UI
본문
Tailwind CSS
Tailwind CSS는 CSS 우선 구성 방식을 사용하므로, @theme 디렉티브를 통해 디자인 토큰을 CSS에서 직접 정의할 수 있어요. 이렇게 하면 테마가 이식 가능하고 유지보수하기 쉬우며 커스터마이즈하기 편리해집니다.
@import "tailwindcss";
@import "@nuxt/ui";
@theme {
/* Your custom design tokens go here */
}
[!NOTE] See: https://tailwindcss.com/docs/theme
사용 가능한 모든 테마 변수 커스터마이즈 옵션은 Tailwind CSS 문서에서 확인해 보세요.
[!TIP]
Tailwind CSS v4는 Preflight을 변경해 버튼이 브라우저 기본값과 일치하도록
cursor: pointer대신cursor: default를 사용해요. pointer 커서를 전역적으로 복원하려면 CSS에 다음 기본 스타일을 추가해 주세요:@layer base { button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; } }
폰트 (Fonts)
--font-* 테마 변수를 사용해 프로젝트의 글꼴 유틸리티를 커스터마이즈할 수 있어요.
@import "tailwindcss";
@import "@nuxt/ui";
@theme {
--font-sans: 'Public Sans', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', monospace;
}
Nuxt:
[!NOTE] See: /docs/getting-started/integrations/fonts
여기에 정의된 폰트는
@nuxt/fonts모듈에 의해 자동으로 로드되고 최적화됩니다.
색상 (Colors)
--color-* 테마 변수를 사용해 색상을 커스터마이즈하거나 기본 색상을 재정의할 수 있어요.
@import "tailwindcss";
@import "@nuxt/ui";
@theme static {
/* Override default green color */
--color-green-50: #EFFDF5;
--color-green-100: #D9FBE8;
--color-green-200: #B3F5D1;
--color-green-300: #75EDAE;
--color-green-400: #00DC82;
--color-green-500: #00C16A;
--color-green-600: #00A155;
--color-green-700: #007F45;
--color-green-800: #016538;
--color-green-900: #0A5331;
--color-green-950: #052E16;
/* Define new custom color */
--color-brand-50: #fef2f2;
--color-brand-100: #fee2e2;
--color-brand-200: #fecaca;
--color-brand-300: #fca5a5;
--color-brand-400: #f87171;
--color-brand-500: #ef4444;
--color-brand-600: #dc2626;
--color-brand-700: #b91c1c;
--color-brand-800: #991b1b;
--color-brand-900: #7f1d1d;
--color-brand-950: #450a0a;
}
[!WARNING]
커스텀 색상을 추가할 때는 각 색상에 대해
50부터950까지 모든 명암(shade)을 반드시 정의해야 해요.
중단점 (Breakpoints)
--breakpoint-* 테마 변수를 사용해 중단점을 커스터마이즈할 수 있어요.
@import "tailwindcss";
@import "@nuxt/ui";
@theme {
--breakpoint-3xl: 1920px;
--breakpoint-4xl: 2560px;
--breakpoint-5xl: 3840px;
}
모션 (Motion)
--ease-* 테마 변수를 사용해 프로젝트의 애니메이션과 이동 전환의 이징(easing)을 커스터마이즈할 수 있어요.
@import "tailwindcss";
@import "@nuxt/ui";
@theme {
--ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
등장/퇴장 애니메이션은 --ease-out 위에서, 불확정(indeterminate) 로딩 애니메이션은 --ease-in-out 위에서 실행되므로, 이 둘을 재정의하면 라이브러리 전체의 타이밍이 바뀝니다.
[!NOTE]
prefers-reduced-motion이 설정되면 오버레이가 확대·축소나 슬라이드 대신 제자리에서 페이드되며, 이동 전환은 비활성화됩니다.
색상 시스템 (Color System)
Nuxt UI의 색상 시스템은 특정 색상 값이 아닌 시맨틱 네이밍을 중심으로 설계됐어요. 이 접근 방식은 UI를 더 유지보수하기 쉽게 만들고 테마 전환을 쉽게 해 줍니다.
시맨틱 색상 (Semantic colors)
Nuxt UI는 색상의 용도(purpose) 를 설명하는 시맨틱 색상 별칭을 제공해요. 각 별칭은 @theme 구성의 색상(기본 Tailwind CSS 팔레트에 추가로 정의하는 어떤 색상이든 가능)을 기반으로 정의됩니다.
| Color | Default | Description |
|---|---|---|
primary |
green |
Main CTAs, active navigation, brand elements, important links |
secondary |
blue |
Secondary buttons, alternative actions, complementary UI elements |
success |
green |
Success messages, completed states, positive confirmations |
info |
blue |
Info alerts, tooltips, help text, neutral notifications |
warning |
yellow |
Warning messages, pending states, attention-needed items |
error |
red |
Error messages, validation errors, destructive actions |
neutral |
slate |
Text, borders, backgrounds, disabled states |
이 시맨틱 색상들은 Nuxt UI 컴포넌트의 color prop에서 사용할 수 있어요:
<template>
<UButton color="primary">
Save Changes
</UButton>
</template>
[!NOTE]
헤더의 테마 메뉴를 눌러 색상 구성이 전체 UI에 어떻게 영향을 주는지 즉시 확인하거나, 테마 편집기를 열어 한 번에 모두 커스터마이즈해 보세요!
런타임 구성 (Runtime configuration)
Nuxt:
이 색상들은 app.config.ts 파일의 ui.colors 키 아래에서 런타임에 구성할 수 있어요. 이렇게 하면 서버를 재시작하지 않고도 동적으로 테마를 커스터마이즈할 수 있습니다.
export default defineAppConfig({
ui: {
colors: {
primary: 'blue',
secondary: 'purple',
neutral: 'zinc'
}
}
})
Vue:
vite.config.ts 파일의 ui.colors 키 아래에서 런타임에 이 색상들을 구성할 수 있어 동적 테마 커스터마이즈가 가능해요:
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: 'blue',
secondary: 'purple',
neutral: 'zinc'
}
}
})
]
})
[!CAUTION]
테마에 존재하는 색상만 사용할 수 있어요. 다음 중 하나를 선택하세요:
- Tailwind의 기본 색상 사용 (예:
blue,green,zinc)@theme디렉티브로 커스텀 색상을 먼저 정의 (위 예시의brand처럼)
색상 확장 (Extend colors)
기본값을 넘어 추가적인 시맨틱 색상을 정의하고 싶을 수 있어요. 예를 들어 tertiary 색상을 추가하는 경우를 살펴볼게요:
Nuxt:
먼저 nuxt.config.ts의 ui.theme.colors 키 아래에 새 색상을 등록해 주세요:
export default defineNuxtConfig({
ui: {
theme: {
colors: [
'primary',
'secondary',
'tertiary',
'info',
'success',
'warning',
'error'
]
}
}
})
그런 다음 app.config.ts의 ui.colors 키 아래에서 값을 지정해 주세요:
export default defineAppConfig({
ui: {
colors: {
primary: 'blue',
secondary: 'purple',
tertiary: 'indigo'
}
}
})
Vue:
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({
theme: {
colors: [
'primary',
'secondary',
'tertiary',
'info',
'success',
'warning',
'error'
]
},
ui: {
colors: {
primary: 'blue',
secondary: 'purple',
tertiary: 'indigo'
}
}
})
]
})
마지막으로 color prop을 지원하는 컴포넌트나 클래스로 이 새 색상을 사용해 주세요:
<UButton color="tertiary">
Special Action
</UButton>