• Empleos
  • Sobre nosotros
  • Empleos
    • Inicio
    • Empleos
    • Cursos y retos
  • Empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

150
Vistas
dynamically set hover value in tailwind css

I want to set a different text color hover depending on categories name with tailwind. I set a config with each color code refering to a category like this :

tailwind.config.js

theme: {
    extend: {
      }
    },
    colors: {
      transparent: 'transparent',
      current: 'currentColor',
      "animation": "#A72608",
      "decor": "#E0AFA0",
      "illustrations": "#32936F",
      "developpement-visuel": "#C2FCF7",
      "realisations": "#FEEA00",
      "croquis": "#9F6BA0",
      "white": "#FFFFFF",
    },

and using it like this in my component :

sidebar.js

<nav>
                    <ul>
                        {categories.map((category) => {
                            return (
                                <li key={category.id} className="mb-4">
                                    <Link href={`/category/${category.attributes.slug}`}>
                                        <a className={`hover:text-${category.attributes.slug} uppercase font-light text-sm`} 
                                        >{category.attributes.name}</a>
                                    </Link>
                                </li>
                            )
                        })}
                    </ul>
                </nav>

but it turns out that it doesn't work. When I look at the devtools ${category.attributes.slug} is effectively replace be the name of the category and the name I gave in my config

over 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Can you try to config hover effect for text color in tailwind.config.js

module.exports = {
   variants: {
        textColor: ['group-hover', 'hover'], 
   }
}
over 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda