Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!