Home > Angular 2 > Angular 2: Adding bootstrap css framework

Angular 2: Adding bootstrap css framework

In my previous post I showed you how to create an Angular 2 application using angular-cli tool. This post is a continuation of that and in this post I am going to show how to use node package manager npm to add bootstrap stylesheet and wire it up in the application.

I am going to open the nodejs command prompt and install the bootstrap css package to the project using the following command.

C:\>npm install ng2-boostrap –save


If you browse to the node_modules folder you can see the new folder bootstrap was created which contains all the stylesheets as shown below.

Bootstrap CSS added to the angular 2 project

In order to make the stylesheet available for the page we have to add the path of the file to the styles array which is defined in the .angular-cli.json file. Since it is an array you can add multiple stylesheets and the loader will take care of it.


"styles": [

adding css location to the styles array

Now I am going to add some menu with the search text box and a jumbroton layout to give it a nice look.

  <nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">NG Corporationa>
    <ul class="nav navbar-nav">
      <li class="active"><a href="#">Homea>li>
      <li><a href="#">Abouta>li>
      <li><a href="#">Servicea>li>
      <li><a href="#">Contacta>li>
    <form class="navbar-form navbar-right">
      <div class="input-group">
        <input type="text" class="form-control" placeholder="Search">
        <div class="input-group-btn">
          <button class="btn btn-default" type="submit">
            <i class="glyphicon glyphicon-search">i>
  <div class="container">
    <div class="row">
      <div class="jumbotron">
        <h1>NG Corporationh1>      
        <p>A place to use your creativity, innovation and passion to build exciting product for the world.p>

As you can see pretty standard bootstrap template and at the end we have our angular component with the custom selector “app-root”. Last thing we have to do is to run the following command in order to start the application.

C:\>ng serve

And here is the angular 2 application up and running with bootstrap styling.

bootstrap style applied to the website

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: