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

194
Visualizações
How to increase progress bar width with Tailwind Animation in Typescript/React

I have a simple progress bar component like below and I would like to add animation like increasing width 0% to 100% once stepCount > 0 is true. (i.e. use s.stepBarProgressed)

<div className={s.stepBarContainer}>
  <div className={s.stepBarDefault}>
    <div
      id="bar" 
      className={stepCount > 0 ? s.stepBarProgressed : s.stepBarNoProgressed} 
    />
  </div>
</div>

then my tailwind css is like this

.stepBarContainer {
  @apply w-1/6 items-center content-center flex;
}

.stepBarDefault {
  @apply w-auto bg-gray-300 rounded items-center align-middle flex-1;
}

.stepBarProgressed {
  @apply animate-bounce;
  @apply bg-teal-main text-xs leading-none py-1 text-center text-gray-600 rounded;
}

.stepBarNoProgressed {
  @apply animate-bounce;
  @apply bg-gray-300 text-xs leading-none py-1 text-center text-gray-600 rounded;
}

I've tried to add eventlistner like below but it didn't work - any way I can natively implement such animation just using Tailwind or anyway with Typescript function?

const stepChange = () => {
  document.addEventListener('click', function() {
    let progress = 0
    const intervalSpeed = 10
    const incrementSpeed = 1
    const bar = document.getElementById('bar')
    const progressInterval = setInterval(function() {
      progress += incrementSpeed
      bar!.style.width = `${progress}%`
      if(progress >= 100) {
        clearInterval(progressInterval)
      }
    }, intervalSpeed)
  })
}
about 4 years ago · Juan Pablo Isaza
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