Download
Please note that the sample project does not include the Metronic Tailwind CSS source files by default. To integrate the styles, you need to copy the Metronic Tailwind CSS source files from your downloaded Metronic folder.
Copy Source Folder
src
folder from the
metronic-tailwind-html
package and paste it into the Angular
src
directory. Rename the copied folder to
metronic
so that the directory structure should now look like this:
src/metronic
.
This step imports the necessary styles and assets from the original HTML package into your Angular project.
src/metronic/core
folder, delete the unnecessary
index.ts
file. This file is not needed for Single Page Application (SPA) integration as it could cause conflicts. Instead, rename the
index.spa.ts
file to
index.ts
to ensure proper integration.
Copy Media Folder
media
folder from the
metronic-tailwind-html
package's
dist/assets/media
directory into your Angular project's
src/assets
directory. The resulting directory structure should look like this:
src/assets/media
.
Install Packages & Start Development Server
npm install
. Start the Angular development server by running
ng serve
.
npm install
ng serve
Creating Project
Install Node.js and Npm
Before starting with Angular, ensure you have Node.js and npm (Node Package Manager) installed on your machine. Visit https://nodejs.org/ to download and install the latest version.Install Angular CLI
npm install -g @angular/cli
Create an Angular Project
ng new tailwind-angular
scss
when creating your project.
Serve the Angular Application
cd tailwind-angular
ng serve
http://localhost:4200
to see your new Angular app in action.
Integrate Styles
Install Dependencies
npm install -D tailwindcss postcss autoprefixer sass
npm install mini-svg-data-uri @popperjs/core
npx tailwindcss init
The command will install the necessary dependencies for Tailwind CSS and Metronic. If you wish to use additional features like
apexcharts
,
axios
, or
clipboard
, you must install them separately.
Copy Source Folder
src
folder from the
metronic-tailwind-html
package and paste it into the Angular
src
directory.
metronic
. The Angular directory structure should now look like this:
src/metronic
src/metronic/core
folder, delete the unnecessary
index.ts
file. This file is not needed for Single Page Application (SPA) integration as it could cause conflicts. Instead, rename the
index.spa.ts
file to
index.ts
to ensure proper integration.
Copy media folder
media
folder from the
metronic-tailwind-html
package's
dist/assets
directory into your Angular project's assets directory.
The resulting directory structure should look like this:
src/assets/media
.
Import Styles
src/styles.scss
and add the following import statement:
// Main style
@tailwind base;
@tailwind components;
@tailwind utilities;
// Keenicons
@import "./metronic/vendors/keenicons/duotone/style.css";
@import "./metronic/vendors/keenicons/filled/style.css";
@import "./metronic/vendors/keenicons/outline/style.css";
@import "./metronic/vendors/keenicons/solid/style.css";
Copy Tailwind Configuration
tailwind.config.js
file from the
metronic-tailwind-html
package to the root of your
Angular project.
content
and
plugins
array:
// ...
content: [
"./src/**/*.{html,ts}",
],
// ...
tailwind.config.js
file. Replace
src/core/plugins
with
src/metronic/core/plugins
for each plugin path.
// ...
plugins: [
require('./src/metronic/core/plugins/plugin'),
require('./src/metronic/core/plugins/components/theme'),
// ... and so on
],
// ...
Disable Strict Mode
tsconfig.json
file and set the
strict
property to
false
.
{
"compilerOptions": {
"strict": false,
// ... other options
},
}
Integrate Core
App component
app.component.ts
file and add the following import statements:
import KTComponents from '../metronic/core/index';
import KTLayout from '../metronic/app/layouts/demo1';
AfterViewInit
lifecycle hook to initialize the components:
ngAfterViewInit(): void {
KTComponents.init();
KTLayout.init();
}