#Nuxt UI V3 Colors Override
7 messages · Page 1 of 1 (latest)
To override all Nuxt UI v3 default colors, you can follow these steps:
- Create or modify your
app.config.tsfile to set the primary and gray colors:
export default defineAppConfig({
ui: {
primary: 'your-primary-color',
gray: 'your-gray-color'
}
})
Replace 'your-primary-color' and 'your-gray-color' with the colors you want to use. You can use any of the Tailwind CSS colors (https://tailwindcss.com/docs/customizing-colors#color-palette-reference) or your own custom colors Getting-started > Colors (https://ui.nuxt.com/getting-started/theming#colors).
- If you're using custom colors, you need to define them in your
tailwind.config.tsfile. Make sure to define all shades from 50 to 950:
import type { Config } from 'tailwindcss'
import defaultTheme from 'tailwindcss/defaultTheme'
export default <Partial<Config>>{
theme: {
extend: {
colors: {
'your-primary-color': {
50: '#...',
100: '#...',
// ... define all shades up to 950
950: '#...'
},
'your-gray-color': {
50: '#...',
100: '#...',
// ... define all shades up to 950
950: '#...'
}
}
}
}
}
You can use tools like uicolors.app (https://uicolors.app/) to generate these color shades Getting-started > Colors (https://ui.nuxt.com/getting-started/theming#colors).
- If you want to override colors for specific components, you can do so in your
app.config.ts:
export default defineAppConfig({
ui: {
button: {
default: {
color: 'your-custom-color'
}
}
// Add other component overrides as needed
}
})
- For colors that are not automatically detected (like dynamic colors or default colors set in
app.config.ts), you need to safelist them in yournuxt.config.ts:
export default defineNuxtConfig({
ui: {
safelistColors: ['your-primary-color', 'your-gray-color', 'other-colors']
}
})
This ensures that the CSS for these colors is generated Getting-started > Colors > Smart Safelisting Part 2 (https://ui.nuxt.com/getting-started/theming#smart-safelisting).
By following these steps, you can override all Nuxt UI v3 default colors and customize the appearance of your components.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@hazy lichen Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@harsh pumice you're talking about ui 2 which use Tailwindcss v3 ui3.nuxt use Tailwindcss v4
Let me check the knowledge base for you again. One moment! :books:
I apologize for the confusion in my previous response. You are correct, and I thank you for pointing that out. Let me clarify the situation regarding Nuxt UI v3 and its use of Tailwind CSS v4.
You're right that Nuxt UI v3 uses Tailwind CSS v4, which is different from the previous version I mistakenly referred to. Unfortunately, the knowledge sources provided do not contain specific information about Nuxt UI v3 and its integration with Tailwind CSS v4.
The documents I have access to primarily discuss Nuxt UI v2 and its use of Tailwind CSS v3. Without accurate and up-to-date information about Nuxt UI v3 and Tailwind CSS v4, I cannot provide a reliable answer to your question about overriding colors in this newer version.