Bootstrap is a CSS framework that gives you ready-made styles and components such as buttons, grids, cards, forms, alerts, and modals. In Angular, the most reliable setup is to install Bootstrap with npm and then register its CSS and JavaScript files in angular.json.
Table of Contents
This guide also shows how to add Font Awesome icons and a Google Font globally.
Prerequisites
Before starting, make sure you already have an Angular project.
ng new my-bootstrap-app
cd my-bootstrap-appIf your project already exists, open a terminal inside the project root. This is the folder that contains angular.json and package.json.
Step 1: Install Bootstrap and Font Awesome
Install Bootstrap and Font Awesome from npm:
npm install bootstrap @fortawesome/fontawesome-free --saveThis adds both packages to package.json and downloads them into the node_modules folder.
Bootstrap provides the UI styles and JavaScript behavior. Font Awesome provides icon classes such as fa-solid fa-user.
Step 2: Configure styles and scripts in angular.json
Open angular.json and find the project build configuration:
"architect": {
"build": {
"options": {
"styles": [],
"scripts": []
}
}
}Add Bootstrap and Font Awesome to the styles array. Add Bootstrapβs bundle file to the scripts array:
"styles": [
"node_modules/@fortawesome/fontawesome-free/css/all.css",
"node_modules/bootstrap/dist/css/bootstrap.css",
"src/styles.css"
],
"scripts": [
"node_modules/bootstrap/dist/js/bootstrap.bundle.js"
]If your project uses SCSS, the global stylesheet may be src/styles.scss instead of src/styles.css. Keep the file name that already exists in your project.
The Bootstrap bundle includes the JavaScript required by components such as dropdowns, modals, offcanvas panels, tooltips, and collapses.
Step 3: Restart the Angular development server
After editing angular.json, stop and restart the Angular server. Angular does not always reload configuration changes while the server is running.
ng serveOpen the application in the browser:
http://localhost:4200/Step 4: Test Bootstrap
Open app.component.html and add a Bootstrap button:
<button type="button" class="btn btn-success">Click Me</button>If the button appears green, Bootstrap CSS is working.
You can also test a Font Awesome icon:
<i class="fa-solid fa-house"></i>If the house icon appears, Font Awesome is working.
Step 5: Add a Google Font
Go to Google Fonts and search for the font you want. For example, you can use the Ubuntu font.
Copy the @import code from Google Fonts and paste it at the top of your global stylesheet, such as src/styles.css or src/styles.scss.
@import url("https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&display=swap");
body {
font-family: "Ubuntu", sans-serif;
}This makes the font available across the whole Angular application.
Alternative: Use CDN links
You can also add Bootstrap, Font Awesome, or Google Fonts through CDN links in src/index.html. This is quick for demos, but npm installation is better for real Angular projects because dependencies are versioned in package.json.
Example CDN placement:
<head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css"
/>
</head>Use either npm configuration or CDN links. Avoid loading the same library both ways because it can increase page size and sometimes create style conflicts.
Common mistakes
- Editing the wrong
stylesarray inangular.json. Make sure you edit the one under the correct project and build target. - Forgetting to restart
ng serveafter changingangular.json. - Using
styles.cssin the config when the project actually usesstyles.scss. - Adding Bootstrap JavaScript but forgetting Bootstrap CSS.
- Loading Bootstrap from both npm and CDN at the same time.
Final check
Your setup is complete when:
npm installfinishes without errors.angular.jsonincludes Bootstrap and Font Awesome paths.ng serveruns successfully.- Bootstrap classes such as
btn btn-successapply correctly in the browser.