๐Ÿ…ฐ๏ธ Integrating Bootstrap 5 with Angular 19 in 2025 ๐Ÿš€

๐Ÿ…ฐ๏ธ Integrating Bootstrap 5 with Angular 19 in 2025 ๐Ÿš€

Angular Bootstrap

This tutorial is part of the Angular 19 from Zero to Hero series, designed to help you master Angular from the ground up in 2025. Whether you are an absolute beginner looking to start your journey or an experienced developer upgrading to Angular 19, this guide will provide you with a hands-on approach to integrating Bootstrap 5 seamlessly into your Angular applications. By the end of this tutorial, you will be equipped with the knowledge to build sleek, responsive, and professional-grade UI components using the latest best practices in modern front-end development.

๐Ÿ”น Overview

This tutorial is your ultimate guide to integrating Bootstrap 5 with Angular 19. Weโ€™ll cover everything from installation to using Bootstrap UI components in multiple ways. Whether you're new to Angular or upgrading to Angular 19, this guide will help you build professional, modern UI components.

๐Ÿ“Œ What Youโ€™ll Learn

โœ… Installing Bootstrap 5 in Angular 19 using npm, CDN, and Angular CLI
โœ… Using Bootstrap components in Angular (Navbars, Grids, Modals, Forms, Tabs, Tooltips, Carousels, and more)
โœ… Exploring ng-bootstrap vs. ngx-bootstrap vs. vanilla Bootstrap
โœ… Configuring Bootstrap using angular.json, styles.css, and index.html
โœ… Leveraging Angular Bootstrap templates for rapid UI development

Let's get started! ๐ŸŽฏ


๐Ÿš€ Why Use Angular 19 with Bootstrap 5?

Both Angular 19 and Bootstrap 5 are widely adopted frameworks that provide the foundation for building modern, efficient, and visually appealing web applications. Each framework brings its own strengths to the table:

  • ๐Ÿ”น Angular 19 โ†’ A highly scalable, fast, and component-driven architecture, ideal for building complex single-page applications (SPAs) with robust data handling and seamless UI interactions.
  • ๐Ÿ”น Bootstrap 5 โ†’ A sleek, responsive UI toolkit that offers a comprehensive set of pre-designed components, utility classes, and a mobile-first grid system, making it easier to build attractive and functional user interfaces.

By combining these two powerful technologies, you gain access to a high-performance, structured, and maintainable front-end development stack that enhances both user experience and developer efficiency.


๐Ÿ“Œ Prerequisites

Before we begin, make sure you have:

  • โœ… A fundamental understanding of HTML, CSS, JavaScript, and TypeScript.
  • โœ… Installed Node.js (LTS) โ†’ Download to ensure you have access to the latest stable version required for modern development workflows.
  • โœ… Installed Angular CLI 19, which provides essential tools for generating and managing Angular projects efficiently.
  • โœ… A code editor like VS Code with the Angular and TypeScript extensions installed for enhanced development productivity.
  • โœ… Basic knowledge of command-line operations to execute Angular CLI commands smoothly.

๐Ÿ”น Check Your Setup

Run the following commands to check if Node.js and Angular CLI are installed:

node -v
ng version

If Angular CLI is not installed, install it using:

npm install -g @angular/cli


๐Ÿ”ง Installing Bootstrap 5 in Angular 19

There are multiple approaches to integrating Bootstrap into an Angular 19 project, each with its own advantages. Whether you prefer integration via npm, using a CDN, adding it through styles.css, or leveraging dedicated Angular Bootstrap libraries, you can choose the method that best suits your development needs. Letโ€™s explore four primary methods:

๐Ÿ”น Method 1: Installing via npm (Recommended)

This method provides better control over dependencies and allows seamless integration with Angular's build process. It ensures that you always have the latest Bootstrap features and updates while keeping everything within your project's ecosystem.

Step 1: Create a New Angular 19 Project

Feel free to skip this step if you already have a project.

If you don't! Please, run the following command to create a new Angular 19 project:

ng new angular-bootstrap-example

Choose CSS as the default stylesheet format when prompted. This ensures compatibility with Bootstrapโ€™s styles and simplifies the integration process. You can later switch to SCSS or other preprocessor options if needed for advanced styling.

Step 2: Navigate to the Project Directory

cd angular-bootstrap-example

Step 3: Install Bootstrap 5

npm install bootstrap

Step 4: Include Bootstrap in angular.json and add Bootstrap files understylesandscripts arrays:

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
  "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
]

Step 5: Serve the Angular 19 Project

ng serve

Your app will be available at http://localhost:4200/.


๐Ÿ”น Method 2: Using Bootstrap via CDN (Quick & Easy)

Using Bootstrap via a CDN is an excellent option when you want to quickly integrate Bootstrap into your Angular project without increasing your build size. This method ensures that your project loads the latest Bootstrap styles and scripts directly from a CDN, reducing the need to manage updates manually. Additionally, since CDNs are optimized for performance and caching, users will experience faster load times when accessing your application. However, an active internet connection is required, which might be a limitation for offline development.

Step 1: Add Bootstrap to index.html

Open src/index.html and add the following inside <head>:

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">

Before </body>, add:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

This method reduces build size but requires an internet connection.


๐Ÿ”น Method 3: Adding Bootstrap in styles.css

Using Bootstrap via the styles.css file is another efficient method for integration. This approach is particularly useful when you want to avoid modifying the angular.json file or including Bootstrap via a CDN. By importing Bootstrap directly into styles.css, you ensure that its styles are applied globally without requiring additional configurations. However, note that this method does not load Bootstrapโ€™s JavaScript functionalities, meaning interactive components such as modals, dropdowns, and tooltips will not work unless you manually import the necessary Bootstrap scripts elsewhere in your project.

Instead of modifying angular.json, you can include Bootstrap in your global styles:

Step 1: Open src/styles.css

Add:

@import "~bootstrap/dist/css/bootstrap.css";

This method only loads Bootstrap styles, not JavaScript functionalities.


๐Ÿ”น Method 4: Using Angular Bootstrap Libraries

Using Angular-specific Bootstrap libraries such as ng-bootstrap and ngx-bootstrap provides several advantages over directly using Bootstrap's JavaScript files. These libraries offer:

  • Seamless Angular Integration โ€“ They are designed to work natively with Angularโ€™s reactive framework, avoiding conflicts with Angularโ€™s change detection.
  • No jQuery Dependency โ€“ Unlike standard Bootstrap, ng-bootstrap and ngx-bootstrap eliminate the need for jQuery, making your application leaner and more Angular-friendly.
  • Optimized Performance โ€“ These libraries use Angular directives and components, improving maintainability and performance compared to manually managing Bootstrapโ€™s JavaScript behaviors.
  • Modular Approach โ€“ With ngx-bootstrap, you only import the specific Bootstrap components you need, reducing the final bundle size of your Angular application.

By using these libraries, you ensure that your Angular application remains fully optimized, maintainable, and free from unnecessary dependencies.

Instead of using vanilla Bootstrap, you can use ng-bootstrap or ngx-bootstrap as follows:

Option 1: Using ng-bootstrap (No jQuery)

1๏ธโƒฃ Install ng-bootstrap:

ng add @ng-bootstrap/ng-bootstrap

2๏ธโƒฃ Import it in app.module.ts:

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

@NgModule({
  imports: [NgbModule],
})
export class AppModule {}

Now you can use Bootstrap components like modals, carousels, and alerts in Angular without jQuery.

Option 2: Using ngx-bootstrap

1๏ธโƒฃ Install ngx-bootstrap:

npm install ngx-bootstrap

2๏ธโƒฃ Import Bootstrap modules in app.module.ts:

import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ModalModule } from 'ngx-bootstrap/modal';

@NgModule({
  imports: [
    BsDropdownModule.forRoot(),
    ModalModule.forRoot()
  ],
})
export class AppModule {}

Difference: ngx-bootstrap uses modular imports, reducing bundle size.


๐Ÿ“Œ Summary

In this tutorial, we covered: โœ… Installing Bootstrap 5 in Angular 19 using npm, CDN, styles.css, and CLI schematics
โœ… Using Angular-specific Bootstrap libraries (ng-bootstrap and ngx-bootstrap)
โœ… Adding Bootstrap UI components like Navbars, Cards, and Buttons
โœ… Comparing **ng-bootstrap vs. ngx-bootstrap

With this knowledge, you can now build beautiful, responsive, and dynamic UI components for your Angular 19 apps! ๐Ÿš€


๐Ÿ“ข Next Steps

๐Ÿ”น Explore More Bootstrap Components
๐Ÿ”น Try Angular Material alongside Bootstrap
๐Ÿ”น Build a Complete Angular 19 Bootstrap Project

Got question? Send them via X! Happy coding! ๐ŸŽ‰


  • Date: