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

295
Visualizações
Styled component animation with props

Here's what I'm trying to accomplish:

const fallOff = keyframes`
   0% {
    transform: translateY(0px);
    opacity: 1;
   }
   80% {
    opacity: 0;
   }
   100% {
    transform: translateY(120vh);
    opacity: 0;
   }
`;

export const Tiles = styled.div<{
  size: number;
  delay: number;
  fallOff: boolean;
}>`
  width: ${({ size }) => size - 4}px;
  height: ${({ size }) => size - 4}px;
  border: 1px #343434 solid;
  background-color: #191919;

  animation: ${(props) =>
    props.fallOff ? `${fallOff} 1.5s ease-in forward` : null};
  animation-delay: ${({ delay }) => (delay === 1 ? 0 : `${delay + 0.5}s`)};
`;

I have multiple tiles and their fallOff animatino will be triggered by the value fo fallOff. Each of them will get animation-delay per each of their delay value accordingly. When I run this, I'm getting Uncaught Error: It seems you are interpolating a keyframe declaration (jGNlbV) into an untagged string.

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

0

Try it. It Will be work. Take out the choice of the name of the animation in a separate property.

    const Tiles = styled.div<{
      size: number;
      delay: number;
      fallOff: boolean;
    }>`
      width: ${({ size }) => size - 4}px;
      height: ${({ size }) => size - 4}px;
      border: 1px #343434 solid;
      background-color: #191919;
    
      animation: 1.5s ease-in forward;
      animation-name: ${(props) => props.fallOff ? fallOff : null};
      animation-delay: ${({ delay }) => (delay === 1 ? 0 : `${delay + 0.5}s`)};
    `;
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