Giter VIP home page Giter VIP logo

Comments (4)

JatinBrainybuzz avatar JatinBrainybuzz commented on September 28, 2024

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.

justpeterpan avatar justpeterpan commented on September 28, 2024

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.

ThiloHettmer avatar ThiloHettmer commented on September 28, 2024

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.

github-actions avatar github-actions commented on September 28, 2024

This issue is stale because it has been open for 30 days with no activity.

from ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.