Add an UI Library
Key Learning Objectives
- โ๏ธAdd an UI library to your projectLearn how to add Bootstrap, an UI library, to your project to enhance the user interface of your application.
Not specific to Angular, adding this library will enhance the user interface of the application rather then relying on the default browser styles. Discover a comparison of the complete application before and after adding the UI library:
// TODO : add screenshot comparison
What is an UI library?
An UI library is a collection of reusable styled components that can be used to build a user interface. It helps to create a consistent look and feel across the application.
For this course, youโll add Bootstrap to our project.
How to add Bootstrap
Rather than installing it directly, letโs use an Angular library that wraps Bootstrap to facilitate the installation: NG Bootstrap.
The NG-Bootstrap ng add @ng-bootstrap/ng-bootstrap
installation command will install Bootstrap as a dependency in your package.json file and add the necessary configuration to your project.
๐ Instructions
-
Run the following command in your terminal:
-
Stop the server if itโs still running and restart it with the following command:
-
Open the
src/app/app.component.html
file and replace the content with the following code to add Bootstrap classes: -
Check out the small changes in your browser.
โ๏ธ What you learned
You learned how to add a library to an Angular application.
Most Angular libraries use the ng add
command to facilitate the installation process. It avoids relying on npm install
command and additional manual updates of your project configuration.
The next chapters will use Bootstrap classes in html snippets to enhance the user interface of the application.
You wonโt need to explore the Bootstrap documentation, as the snippets will be provided for you.
๐ฆ Quiz
- What is Bootstrap?
- A. A CSS framework
- B. A JavaScript library
- C. A UI library
- D. All of the above
- What is the purpose of ng add?
- A. To add a new component to the application
- B. To add a new library to the application
- C. To add a new service to the application
- D. To add a new module to the application