How to implement the Tailwind CSS with Custom Angular Library ?
Last Updated :
28 Apr, 2025
Tailwind CSS is basically a Utility-first CSS framework for building rapid custom UI. It is a highly customizable, low-level CSS framework that gives you all of the building blocks that you need. Also, 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 client-side TypeScript-based, front-end web framework developed by the Angular Team at Google, that is mainly used to develop scalable single-page web applications(SPAs) for mobile & desktop. Angular CLI (Command Line Interface) is a powerful tool that provides developers with a set of commands for creating, building, testing, and deploying Angular applications and libraries.
Integrating Tailwind CSS into a custom Angular library is widely used in regular Angular projects. In this article, we will see how to use Tailwind CSS in a custom Angular library. Before proceeding, make sure that the Node.js & NPM must be installed in the system.
Steps to Configure TailwindCSS with Angular Library
Step 1: Setup a new project by creating a new directory
- To make the new directory use the 'mkdir' command.
mkdir Tailwind-angular
- Now, navigate inside that directory using the 'cd' command
cd Tailwind-angular
Step 2: Install the Angular CLI
To Install it write the following command in the terminal
npm install -g @angular/cli
Step 3: Creating a new angular project
Make a new angular project via the command 'ng new my-angular-app' and move inside it by 'cd' commands.
ng new my-angular-app
cd my-angular-app
Step 4: Installing TailwindCSS
Install tailwind using NPM using this command
npm install tailwindcss --save-dev
Step 5: Create a Tailwind CSS configuration file
Run the init command from Tailwind CSS to create a new tailwind.config.js file inside the project directory
npx tailwindcss init
JavaScript
// tailwind.config.js
module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
}
Step 6: Import the Tailwind CSS Directives
Add the layer directives of tailwind CSS by writing the following code inside the “./src/styles.css file"
CSS
@tailwind base;
@tailwind components;
@tailwind utilities;
Step 7: Configure your tailwind.config.js
To do that go inside “tailwind.config.js” and update it as given below, so that it will apply tailwind-CSS in all the files.
JavaScript
module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
}
content: [
"./src/**/*.{html,ts}", // add this line
]
- After adding the above line:
JavaScript
module.exports = {
content: [
"./src/**/*.{html,ts}",
],
theme: {
extend: {},
},
plugins: [],
}
Step 8: Project Structure
The below project structure will be generated by following the above commands:

Step 9: Run the Application
The below line of code will generate a localhost server, & follow the server link to open the application on the web browser.
ng serve --open
Example 1: This example illustrates the setting up of Tailwind-CSS with the Angular Library. In the following code, we are using the text class with a <h1> tag & including the bold style which makes the content bold and underlines it. Add Tailwind’s utility classes to style your content inside "./src/app/app.component.html"
HTML
<h1 class="text-3xl font-bold underline">
GeeksforGeeks
</h1>
Output: To run it write the following command in the terminal ng serve --open

Example 2: This example illustrates the successful execution of code after setting up Tailwind-CSS with the Angular Library. In the following code, we are using Tailwind class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 rounded-full" with Button tag which makes the button background blue, text white and round the corners and it changes color when we hover on it.
HTML
<button class="bg-blue-500
hover:bg-blue-700
text-white
font-bold py-2 rounded-full">
clickMe
</button>
Output:
Similar Reads
How to change the width on hover using Tailwind CSS ? In this article, we will change the width on hover using Tailwind. There is no inbuilt method in Tailwind, so you have to customize the tailwind.config.js file. Let's discuss the whole process further in this article.By default, tailwind CSS only generates responsive variants for width utilities. To
3 min read
How To Add Custom Box Shadow In Tailwind CSS? Tailwind CSS is a utility-focused CSS framework. Offers a wide range of design utilities. It does include predefined shading, however, for unique design needs, you might want a custom box shadow that goes beyond the default. in this article, you will learn how to extend Tailwind's default shadow and
3 min read
How to apply background image with linear gradient using Tailwind CSS ? In this article, we will see how to apply background images with a linear gradient using Tailwind CSS. Tailwind CSS is a highly customizable, utility-first CSS framework from which we can use utility classes to build any design. To apply background images with linear gradients we use the background
2 min read
How to Install Tailwind CSS with Create React App? We will see how to set up Tailwind CSS in a React project using the Create React App. Tailwind CSS is a utility-first CSS framework that allows for rapid development of custom user interfaces. When combined with Create React App, it offers a flexible approach to build modern React applications.Prere
2 min read
How to use Ant Design with Tailwind CSS in a React Project ? The integration of Ant Design and Tailwind CSS in a React project presents challenges due to their differing styling conventions. Ant Design offers a feature-rich component library with its own class names, while Tailwind CSS provides a utility-first framework for custom designs. Combining both libr
2 min read
How to add custom styles and ways to add custom styles in Tailwind-CSS ? Tailwind is a popular CSS framework that makes your User Interface design making the process easier. It provides low-level classes and those classes combine to create styles for various components. Tailwind-CSS comes with a bunch of predefined styling but as a developer, we need more custom styling
3 min read
How to Use Custom Percentages in Padding in Tailwind CSS? We know that Tailwind CSS provides a utility-first approach for styling web applications, which makes it easy to apply styles directly in HTML. This article guide will explain how to use custom percentages in padding within Tailwind CSS. Approach: Using Custom Utility ClassesThis approach involves c
2 min read
How To Control The Scroll Snap in Tailwind CSS? To simplify scroll snap effects, a utility-first CSS framework, Tailwind CSS, helps with some utilities. When scroll snapping is in place, users are guided through the content smoothly by snapping elements into position as they scroll down the page, resulting in a more polished and responsive experi
4 min read
How to use CSS Animations with Tailwind CSS ? Tailwind CSS classes are used to style elements and apply animations effortlessly. Utilize Tailwind's animation utility classes to add dynamic visual effects. Combine Tailwind CSS with custom CSS animations for versatile and engaging web designs. Table of Content Tailwind CSS Animation Utility Class
3 min read