Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Reference for Nuxt UI v4 (125+ components built on Reka UI + Tailwind CSS v4) including forms, overlays, and theming.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/theming.md
1# Theming23## Semantic Colors45| Color | Default | Purpose |6| ----------- | ------- | ------------------------------------------- |7| `primary` | green | CTAs, active states, brand, important links |8| `secondary` | blue | Secondary buttons, alternatives |9| `success` | green | Success messages, positive states |10| `info` | blue | Info alerts, help text |11| `warning` | yellow | Warnings, pending states |12| `error` | red | Errors, destructive actions |13| `neutral` | slate | Text, borders, disabled states |1415## Configuring Colors1617### Nuxt (app.config.ts)1819```ts20// app.config.ts21export default defineAppConfig({22ui: {23colors: {24primary: 'indigo',25secondary: 'violet',26success: 'emerald',27error: 'rose'28}29}30})31```3233### Vue (vite.config.ts)3435```ts36ui({37ui: {38colors: {39primary: 'indigo',40secondary: 'violet'41}42}43})44```4546## Adding Custom Colors47481. Register in theme config:4950```ts51// nuxt.config.ts52export default defineNuxtConfig({53ui: {54theme: {55colors: ['primary', 'secondary', 'tertiary'] // Add new color56}57}58})59```60612. Define in CSS (all 11 shades required):6263```css64@theme {65--color-tertiary-50: #fef2f2;66--color-tertiary-100: #fee2e2;67--color-tertiary-200: #fecaca;68--color-tertiary-300: #fca5a5;69--color-tertiary-400: #f87171;70--color-tertiary-500: #ef4444;71--color-tertiary-600: #dc2626;72--color-tertiary-700: #b91c1c;73--color-tertiary-800: #991b1b;74--color-tertiary-900: #7f1d1d;75--color-tertiary-950: #450a0a;76}77```78793. Assign and use:8081```ts82// app.config.ts83export default defineAppConfig({84ui: { colors: { tertiary: 'tertiary' } }85})86```8788```vue89<UButton color="tertiary">Custom Color</UButton>90```9192## CSS Variables9394### Text Utilities9596| Class | Light | Dark | Use |97| ------------------ | ----- | ---- | ------------------------- |98| `text-dimmed` | 400 | 500 | Placeholders, hints |99| `text-muted` | 500 | 400 | Secondary text |100| `text-toned` | 600 | 300 | Subtitles |101| `text-default` | 700 | 200 | Body text |102| `text-highlighted` | 900 | 100 | Headings, emphasis |103| `text-inverted` | 50 | 950 | On dark/light backgrounds |104105### Background Utilities106107| Class | Light | Dark | Use |108| ------------- | ----- | ---- | ----------------- |109| `bg-default` | white | 900 | Page background |110| `bg-muted` | 50 | 800 | Subtle sections |111| `bg-elevated` | white | 800 | Cards, modals |112| `bg-accented` | 100 | 700 | Hover states |113| `bg-inverted` | 900 | 100 | Inverted sections |114115### Border Utilities116117| Class | Light | Dark |118| ----------------- | ----- | ---- |119| `border-default` | 200 | 800 |120| `border-muted` | 100 | 800 |121| `border-accented` | 200 | 700 |122| `border-inverted` | 900 | 100 |123124### Global Variables125126```css127:root {128--ui-radius: 0.25rem; /* Base border radius */129--ui-container: 80rem; /* Container max-width */130--ui-header-height: 4rem; /* Header height */131}132```133134## Custom CSS Variables135136```css137/* assets/css/main.css */138:root {139--ui-primary: var(--ui-color-primary-700);140--ui-radius: 0.5rem;141}142.dark {143--ui-primary: var(--ui-color-primary-200);144}145```146147## Solid Colors (Black/White)148149Can't use `primary: 'black'` - set in CSS:150151```css152:root {153--ui-primary: black;154}155.dark {156--ui-primary: white;157}158```159160## Tailwind Variants Override161162### Global Override (app.config.ts)163164```ts165export default defineAppConfig({166ui: {167button: {168slots: {169base: 'font-bold rounded-full'170},171variants: {172size: {173md: { base: 'px-6 py-3' }174}175},176compoundVariants: [{177color: 'neutral',178variant: 'outline',179class: { base: 'ring-2' }180}],181defaultVariants: {182color: 'neutral',183variant: 'outline'184}185}186}187})188```189190### Per-Component Override191192```vue193<!-- ui prop overrides slots -->194<UButton :ui="{ base: 'font-mono' }">Custom</UButton>195196<!-- class prop overrides root/base slot -->197<UButton class="rounded-none">Square</UButton>198```199200## Matching Theme Structure in app.config201202**CRITICAL**: Components have two theme structure patterns. Your app.config MUST match the component's theme structure.203204### Pattern 1: Slots-Based Themes (Most Components)205206Components like Button, Card, Input, Select use `slots:` in their theme:207208```ts209// Component theme (Button, Card, etc.)210export default {211slots: {212base: '...',213root: '...',214icon: '...'215}216}217```218219**app.config usage**:220221```ts222ui: {223button: {224slots: { base: 'font-bold' } // ✅ Match slots structure225}226}227```228229### Pattern 2: Flat Base Themes (Container, Skeleton, etc.)230231Components like Container, Skeleton, Form, Main use flat `base:` in their theme:232233```ts234// Component theme (Container, Skeleton, etc.)235export default {236base: 'w-full max-w-container'237}238```239240**app.config usage**:241242```ts243ui: {244container: {245base: 'max-w-lg' // ✅ Match flat structure246}247}248```249250### Common Mistake251252```ts253// ❌ WRONG - Don't use slots for flat-base components254ui: {255container: {256slots: { base: 'max-w-lg' } // TypeScript error!257}258}259260// ❌ WRONG - Don't use flat for slots-based components261ui: {262button: {263base: 'font-bold' // Won't work correctly264}265}266```267268### How to Check Component Structure2692701. Check component docs: https://ui.nuxt.com/components/[component]2712. Look at "Theme" section - shows the structure2723. Match that structure in your app.config273274## Component Theme Structure275276```ts277// Each component has slots, variants, compoundVariants, defaultVariants278export default {279slots: {280root: 'relative',281base: 'px-4 py-2',282icon: 'size-5'283},284variants: {285color: {286primary: { base: 'bg-primary text-inverted' },287neutral: { base: 'bg-neutral text-default' }288},289size: {290sm: { base: 'text-sm', icon: 'size-4' },291md: { base: 'text-base', icon: 'size-5' },292lg: { base: 'text-lg', icon: 'size-6' }293}294},295defaultVariants: {296color: 'primary',297size: 'md'298}299}300```301302## Dark Mode303304Handled by `@nuxtjs/color-mode`. Access via:305306```ts307const colorMode = useColorMode()308colorMode.preference = 'dark' // 'light', 'dark', 'system'309```310311```vue312<UColorModeButton /> <!-- Toggle button -->313<UColorModeSelect /> <!-- Dropdown select -->314```315316## Best Practices317318| Do | Don't |319| -------------------------------------- | ----------------------------- |320| Use semantic colors | Hardcode hex values |321| Override via app.config | Modify source theme files |322| Use CSS variables for custom colors | Skip dark mode variants |323| Define all 11 shades for custom colors | Use partial shade definitions |324