Back to InstallationYou are on Angular CLI.
Installation

Angular CLI

Angular uses the JavaScript version of the component, wrapped in one small standalone Angular component. The animation, the reduced-motion branch and the styles stay in the framework-free file.

JavaScriptAngular CLIAngular uses the JavaScript build, wrapped once.

Prerequisites

You need an Angular app, Tailwind CSS v4 and a folder for the framework-free component. The wrapper is plain TypeScript, so it works with standalone components.

  • Node.js 20 or newer and the Angular CLI.
  • Angular 19 or newer, with standalone components.
  • Tailwind CSS v4 through PostCSS.
  • Allow JavaScript imports in tsconfig.json while the vanilla file stays .js.

New app or existing app

Create an Angular app with CSS styles and routing. Skip this if you already have one; the wrapper only needs a component and a host element.

Create an Angular app

npx @angular/cli@latest new my-app --style=css --routing --ssr=false
npmthe default on every machine

Configuration

Tailwind v4 runs through PostCSS and the animated files import motion. Point the styles array at the global stylesheet, then allow the vanilla file in TypeScript. There is no provider: the vanilla component injects its own reduced-motion aware styles.

Install the runtime

npm install tailwindcss @tailwindcss/postcss postcss
npmthe default on every machine

Install the motion runtime

npm install motion
npmthe default on every machine
.postcssrc.json
{
  "plugins": {
    "@tailwindcss/postcss": {}
  }
}
src/styles.css
@import "tailwindcss";
tsconfig.json
{
  "compilerOptions": {
    "allowJs": true,
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

Add a component

Copy the framework-free dialog into src/app/prequelui, then mount it from a standalone component. The wrapper creates one dialog per host and leaves cleanup to Angular.

Copy the framework-free dialog

shell
curl -fsSL --create-dirs https://prequeluianimate.terravidhal.me/r/vanilla/dialog/dialog.js -o src/app/prequelui/dialog/dialog.js
src/app/animated-dialog.component.ts
import {
  AfterViewInit,
  Component,
  ElementRef,
  OnDestroy,
  ViewChild,
} from "@angular/core";
import { createDialog } from "./prequelui/dialog/dialog.js";

@Component({
  selector: "app-animated-dialog",
  standalone: true,
  template: '<div #host class="grid place-items-center"></div>',
})
export class AnimatedDialogComponent implements AfterViewInit, OnDestroy {
  @ViewChild("host", { static: true }) host!: ElementRef<HTMLElement>;
  private dialog?: ReturnType<typeof createDialog>;

  ngAfterViewInit() {
    this.dialog = createDialog(this.host.nativeElement, {
      trigger: "Open dialog",
      title: "An Angular shell",
    });
  }

  ngOnDestroy() {
    this.dialog?.destroy();
  }
}

The vanilla item exports createDialog(root, options) and returns an object with setOpen and destroy. Keep the file in your app so you can tune its durations.

Dark mode

Angular's index.html is the last place to set the class before the bundle paints. The saved choice wins, then the system preference.

src/index.html
<script>
const saved = localStorage.getItem("theme");
const dark =
saved === "dark" ||
(!saved && matchMedia("(prefers-color-scheme: dark)").matches);
document.documentElement.classList.toggle("dark", dark);
</script>

Verification

Run the app, render the wrapper and open the dialog. Check that the styles are present and that reduced motion still changes the state.

  • The trigger renders inside the Angular component's host.
  • The overlay uses the theme tokens in light and dark.
  • Escape and the close button both remove the dialog.
  • Reduced motion removes travel, not the state change.

Start the dev server

npm run start
npmthe default on every machine

More JavaScript guides

All frameworks

Built by Vidhal. The source is available on GitHub.

MIT licensed