![]() |
VOOZH | about |
In this article, we will see how to set up the Tailwind CSS in AngularJS & will understand the different ways for implementation through the examples.
Tailwind CSS is a utility-first CSS framework for rapidly building custom user interfaces. It is a cool way to write inline styling and achieve an awesome interface without writing a single line of your own CSS.
Angular is a platform and framework for building single-page client applications using HTML and TypeScript. Angular is written in TypeScript. It implements core and optional functionality as a set of TypeScript libraries that you import into your applications.
So, let's start with creating a new angular project and setting up Tailwind CSS in the angular project.
Setting up new Angular Project:
ng new project-name
Let them finish the above process.
ng serve --open
Angular setup is done & let's move to install the Tailwind CSS in the angular.
Installing Tailwind CSS in the Angular Project: There are 2 ways to add tailwind CSS in the Angular Project.
Using CDN:
<script src="https://cdn.tailwindcss.com/3.4.16"></script>
It will include all the libraries of the tailwind in the project using the internet. It is an easy way to include the tailwind.
Note: It requires internet. If the internet is not available then it will not work.
Example 1: This example describes the basic implementation of the Tailwind CSS in AngularJS by using the CDN link.
Output:
Using PostCSS:
npm install tailwindcss postcss autoprefixer
tailwind.config.js:
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
postcss.config.js:
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};Now you can use tailwind inline CSS and make more hands dirty you can refer to the tailwind website.
Example 2: This example describes the basic implementation of the Tailwind CSS in AngularJS by installing the tailwind CSS using npm.
Output:
Reference: https://tailwindcss.com/