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.
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=falseConfiguration
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 postcssInstall the motion runtime
npm install motion{
"plugins": {
"@tailwindcss/postcss": {}
}
}@import "tailwindcss";{
"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
curl -fsSL --create-dirs https://prequeluianimate.terravidhal.me/r/vanilla/dialog/dialog.js -o src/app/prequelui/dialog/dialog.jsimport {
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.
<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 startMore JavaScript guides
All frameworks