Animation Basics in Angular

From the Angular cheat sheet · Animations · verified Jul 2026

Animation Basics

Creating animations with Angular animations API

typescript
// Basic animation
import { trigger, state, style, transition, animate } from '@angular/animations';

@Component({
  selector: 'app-animated',
  template: \`
    <div [@slideIn]="isVisible" class="box">
      Animated Content
    </div>
    <button (click)="toggle()">Toggle</button>
  \`,
  animations: [
    trigger('slideIn', [
      transition(':enter', [
        style({ transform: 'translateX(-100%)' }),
        animate('300ms ease-in', style({ transform: 'translateX(0%)' }))
      ]),
      transition(':leave', [
        animate('300ms ease-out', style({ transform: 'translateX(100%)' }))
      ])
    ])
  ]
})
export class AnimatedComponent {
  isVisible = true;
  toggle() { this.isVisible = !this.isVisible; }
}
💡 Use :enter and :leave for elements being added/removed from DOM
⚡ Stagger animations for lists create smooth sequential effects
📌 Standalone apps enable animations with provideAnimations() (provideNoopAnimations() in tests)
🔥 @angular/animations is deprecated in Angular 22 (removed in v23); prefer native CSS animate.enter/animate.leave
Back to the full Angular cheat sheet