Skip to content

chore(docs): add documentation showing how to include bootstrap #3425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/documentation/stories/include-bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Include [Bootstrap](http://getbootstrap.com/)

[Bootstrap](http://getbootstrap.com/) is a popular CSS framework which can be used within an Angular project.
This guide will walk you through adding bootstrap to your Angular CLI project and configuring it to use bootstrap.

Create a new project and navigate into the project
```
ng new my-app
cd my-app
```

With the new project created and ready you will next need to install bootstrap to your project as a dependency.
Using the `--save` option the dependency will be saved in package.json
```
// version 3.x
npm install bootstrap --save

// version 4.x
npm install bootstrap@next --save
```

Now that the project is set up it must be configured to include the bootstrap CSS.

Open the file `angular-cli.json` from the root of your project.
Under the property `apps` the first item in that array is the default application.
There is a property `styles` which allows external global styles to be applied to your application.
Specify the path to `bootstrap.min.css`
```
// version 3.x and 4.x
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
```

With the application configured, run `ng serve` to run your application in develop mode.
In your browser navigate to the application `localhost:4200`.
Make a change to your application to ensure that the CSS library has been included.
A quick test is to add the following markup to `app.component.html`
```
<button class="btn btn-primary">Test Button</button>
```
After saving this file, return to the browser to see the bootstrap styled button.


**Note:** When you make changes to `angular-cli.json` you will need to re-start `ng serve` to pick up configuration changes.