Comments (4)
I have the same problem, I want to be able to change the variable from backend and nuxt UI should be able to change the primary color to whatever color variable I set in tailwind.config.js file similar to you. But it only taking hard color code, no variable are being taken.
export default defineAppConfig({ ui: { primary: 'minimum', gray: 'cool' } })
but its not working. Also I might be new programmer and a little rude but the documentation is not actually good when it comes to use css variable to change the primary color. someone please mention a solution for it.
from ui.
Hey, if I understand correctly, you need to set the value for each color-shade in your Tailwind configuration individually. Based on your example repository, hereβs how you can achieve it:
Index.vue:
<template>
<div>
<p class="text-primary">Nuxt UI Primary</p>
<p class="text-custom-100/20">Custom Primary</p>
<p class="text-custom-500">Custom Primary</p>
</div>
</template>
<script setup lang="ts">
const primaryColor100 = '123 222 123'
const primaryColor500 = '255 255 0'
useHead({
style: [
{
key: 'primary-color-override',
innerHTML: `:root {
--custom-primary-100: ${primaryColor100};
--custom-primary-500: ${primaryColor500};
}`
}
]
})
</script>
tailwind.config.ts
import type { Config } from 'tailwindcss'
export default <Partial<Config>>{
content: [
'./pages/**/*.vue'
],
theme: {
extend: {
colors: {
custom: {
50: 'rgb(var(--custom-primary) / <alpha-value>)',
100: 'rgb(var(--custom-primary-100) / <alpha-value>)',
200: 'rgb(var(--custom-primary) / <alpha-value>)',
300: 'rgb(var(--custom-primary) / <alpha-value>)',
400: 'rgb(var(--custom-primary) / <alpha-value>)',
500: 'rgb(var(--custom-primary-500) / <alpha-value>)',
600: 'rgb(var(--custom-primary) / <alpha-value>)',
700: 'rgb(var(--custom-primary) / <alpha-value>)',
800: 'rgb(var(--custom-primary) / <alpha-value>)',
900: 'rgb(var(--custom-primary) / <alpha-value>)',
950: 'rgb(var(--custom-primary) / <alpha-value>)',
},
}
}
}
}
from ui.
Hi @justpeterpan,
thanks for the reply. I did try to set all color shades with different colors but it does not work either. As soon as I override the primary color shades with a css variable in the tailwind config primary is null.
This is the nuxt ui generated style tag:
<style id="nuxt-ui-colors">:root {
--color-primary-50: null;
--color-primary-100: null;
--color-primary-200: null;
--color-primary-300: null;
--color-primary-400: null;
--color-primary-500: null;
--color-primary-600: null;
--color-primary-700: null;
--color-primary-800: null;
--color-primary-900: null;
--color-primary-950: null;
--color-primary-DEFAULT: var(--color-primary-500);
--color-gray-50: 249 250 251;
--color-gray-100: 243 244 246;
--color-gray-200: 229 231 235;
--color-gray-300: 209 213 219;
--color-gray-400: 156 163 175;
--color-gray-500: 107 114 128;
--color-gray-600: 75 85 99;
--color-gray-700: 55 65 81;
--color-gray-800: 31 41 55;
--color-gray-900: 17 24 39;
--color-gray-950: 3 7 18;
}
.dark {
--color-primary-DEFAULT: var(--color-primary-400);
}
</style>
from ui.
This issue is stale because it has been open for 30 days with no activity.
from ui.
Related Issues (20)
- Type issue with colors/variant in app.config.ts
- Default loading icon is not set on SelectMenu from app config HOT 2
- UTable Expandable questions? HOT 2
- Popover close-prevented HOT 3
- USelectMenu :option-attribute does not handle nested objects
- Default props HOT 1
- Module @nuxt/ui is disabled due to incompatibility issues HOT 4
- Expected styles from a private modules are missing in the production client bundle
- UCarousel with Arrows enabled causes Hydration Attribute Mismatch
- Overflow probem with SelectMenu inside a table HOT 5
- [InputMenu/Select/SelectMenu] Missing `arrow` prop implementation
- [InputMenu/SelectMenu] Combobox `default-value` does not seem to work
- [Slider] Handle tooltip around thumb
- Migrate to Reka UI, the new Radix Vue
- [CommandPalette] Generics not working well with items inside groups
- "UDropdown": Toggle NOT Working in Mobile. click event & touchstart event neutralize each other. HOT 1
- How to add localization?
- :ui prop typescript error with 'strategy' as a string HOT 2
- Migration to `@nuxt/content` v3
- How to use css variables defined in css file in UI HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ui.