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

427
Vistas
Using @apply over creating a component (React. tailwind)

In which scenario is it recommended to use @apply over extracting styles into a component?

Can @apply be used like a replacement for @mixin in sass? If not, what should I use as a replacement for @mixin when working with tailwindcss?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The documentation suggests to use @apply only for small highly reusable things like buttons, inputs, headers etc. Otherwise you'll lose the advantages tailwind gives you.

For larger things suggests to use components, loops etc.

As a side note if you are using @apply more than it is necessary you'll increase tailwind's size, so you'll lose one of the biggest advantages tailwind has.

So you have to find a balance between these 2.

As for the mixin. the only thing you could do is the following in your app.css -tailwind's file-

@layer components {
  .foo {
     @apply mb-2 text-2xl font-bold;
  }

  .bar {
    @apply .foo;
   }
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Generally, It is best to use @apply when applying the same styling across multiple components.

I find it is best to use @apply on your common elements such as h1-6 and p tags. I also like to create common components across my application like Cards or Buttons which use shared "surfaces". You will benefit from creating styles with @apply and then referencing them in the className of these components as you may wish to have common styles such as background color on dark/light mode, hover opacity, responsive sizing, etc...

You don't have to use @apply, and it makes no real difference in terms of performance. However, tailwindcss is a utility framework, so combining utilities into a single class does defeat the purpose of the library. It just makes your dev experience better if you are repeating yourself.

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda