liveBook · Manning

Bootstrap

As explained in Pro Angular 16

Bootstrap is an open-source front-end library providing CSS styles and interface components for responsive web pages and applications.

Bootstrap is a CSS framework that supplies reusable classes for consistent element styling, reducing the need for custom CSS. It also includes JavaScript enhancements, but Angular supplies the interactive behavior here. section 3.3

Apply Bootstrap by assigning its classes to HTML elements:

  • Use bg-primary to set a background color, text-white to set text color, and p-3 to add padding. section 3.3
  • Install Bootstrap 5.2.3 with npm, then add its CSS stylesheet to the Angular build styles configuration. section 3.1 section 20.1.1
  • Account for shell differences when running the configuration command; PowerShell requires a different quoting and escaping form. section 3.1

Styling a heading

Assigning class="bg-primary text-white p-3" to a heading applies Bootstrap’s background, text-color, and padding styles without defining custom rules. section 3.3

Listing 3.2. Installing the Bootstrap CSS package
npm install bootstrap@5.2.3

Install the Bootstrap CSS package with npm before adding its stylesheet to the Angular build configuration. section 3.1

Listing 3.3. Changing the application configuration
ng config projects.Primer.architect.build.options.styles '["src/styles.css", "node_modules/bootstrap/dist/css/bootstrap.min.css"]'

Add node_modules/bootstrap/dist/css/bootstrap.min.css beside the application stylesheet in the Angular styles configuration. section 3.1

How Pro Angular 16 covers it

How deep it goes
Explains CSS classes and setup commands with small examples, but defers detailed Bootstrap documentation and does not use its JavaScript features.
Examples
Demonstrates bg-primary, text-white, and p-3 on a to-do-list heading, then integrates the stylesheet into Angular projects.
What it assumes
Assumes basic HTML elements and teaches that CSS properties and selectors control presentation before applying Bootstrap classes.
What you can do after
Operate/configure Bootstrap by installing its npm package, registering its stylesheet, and applying utility classes to HTML.
How it connects
Connects HTML elements, CSS properties and selectors, Angular build configuration, npm packages, and Angular Material style conflicts.

Also explained in

Compare how 3 books explain Bootstrap →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.