Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
What is the best way to write different css or scss for the same component?

Imagine that I have a complex component like a dropdown menu and I want it to have some custom styles when I use it in different places. Not only colors, but spacing and icons too.

If I'm using something like react, or vue, I could pass parameters to the props.

We can also use only scss, and there are a lot of ways of overwriting the styles:

.dropdown{
 width: 100px
}

//overwrite for my custom menu
.my-custom-menu{
 .dropdown{
   width: 120px;
  }
}

Or if using something like BEM, I could even make the main class name a variable and change it:

.dropdown{
  &__container{
    width: 100px;
  }
}

//custom
.other-dropdown{
 &__container{
   width: 120px;
  }
}

What is the best way? Are there other ways of doing this?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Make your component re-usable. You just add style for modifed states or context like dark, light big, small** etc.

.dropdown{
  &__container{
    width: 100px;
  }
}

//custom

.dropdown{
 
 &.dark {
  color: dark;
 }
 
 
 &.light {
  color: white;
 }
  
}

And this is work for all components so far.

you had:

--dropdown
--dropdown__container
--container-small
--container-big
about 4 years ago · Santiago Trujillo 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda