Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
When extending TailwindCSS' theme, how can I include a new class that uses two drop-shadow() rules?

I'm creating a React App with TailwindCSS. I'm using the built-in drop-shadow-md utility class, which, in CSS, is equal to the following rule as per the Tailwind docs:

filter: drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06))

What I need to do is simply turn the y-offset values in both function calls (the second argument for the drop-shadow function) to negative values, because I want to use the same computation to display a shadow on the top of a component (a navbar fixed to the bottom of the screen of a PWA).

So far I've been able to extend my theme by adding a custom class md-top, but I can only add the first drop-shadow() call that the original drop-shadow-md class includes. I can't find the way to add the second drop-shadow() call.

This is the relevant part of my tailwind.config.js file:

theme: {
    extend: {
      dropShadow: {
        'md-top': '0 -4px 3px rgb(0 0 0 / 0.07)',
      }
    },
  },

How can I add that second function call in the Tailwind configuration file?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

An alternate solution is to register a plugin, as described in (Tailwind's Docs).

In your tailwind.config.js file, in the plugins section, add this:

const plugin = require('tailwindcss/plugin') // import Tailwind's 'plugin' function

module.exports = {
  content: [],
  theme: {},
  plugins: [
    plugin(function ({ addUtilities }) {
      addUtilities({
        '.custom-shadow':
          { 'filter': 'drop-shadow(0 -4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 -2px 2px rgb(0 0 0 / 0.06));' }
      }
      )
    }),
  ]

Then, in your jsx, it's accessible via the new class name custom-shadow like this:

<div className='custom-shadow' />

Hovering in VScode shows the expected CSS output!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda