Skip to content

Commit cdf717a

Browse files
delastevefilipesilva
authored andcommitted
chore(docs): update bootstrap documentation
Close #4115
1 parent 20490cc commit cdf717a

File tree

1 file changed

+78
-24
lines changed

1 file changed

+78
-24
lines changed

docs/documentation/stories/include-bootstrap.md

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,119 @@
33
[Bootstrap](http://getbootstrap.com/) is a popular CSS framework which can be used within an Angular project.
44
This guide will walk you through adding bootstrap to your Angular CLI project and configuring it to use bootstrap.
55

6+
## Using CSS
7+
8+
### Getting Started
9+
610
Create a new project and navigate into the project
11+
712
```
813
ng new my-app
914
cd my-app
1015
```
1116

17+
### Installing Bootstrap
18+
1219
With the new project created and ready you will next need to install bootstrap to your project as a dependency.
1320
Using the `--save` option the dependency will be saved in package.json
14-
```
15-
// version 3.x
21+
22+
```sh
23+
# version 3.x
1624
npm install bootstrap --save
1725

18-
// version 4.x
26+
# version 4.x
1927
npm install bootstrap@next --save
2028
```
2129

30+
### Configuring Project
31+
2232
Now that the project is set up it must be configured to include the bootstrap CSS.
2333

24-
Open the file `angular-cli.json` from the root of your project.
25-
Under the property `apps` the first item in that array is the default application.
26-
There is a property `styles` which allows external global styles to be applied to your application.
27-
Specify the path to `bootstrap.min.css`
28-
```
29-
// version 3.x and 4.x
30-
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
34+
- Open the file `angular-cli.json` from the root of your project.
35+
- Under the property `apps` the first item in that array is the default application.
36+
- There is a property `styles` which allows external global styles to be applied to your application.
37+
- Specify the path to `bootstrap.min.css`
38+
39+
It should look like the following when you are done:
40+
```json
41+
"styles": [
42+
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
43+
"styles.css"
44+
],
45+
```
46+
47+
**Note:** When you make changes to `angular-cli.json` you will need to re-start `ng serve` to pick up configuration changes.
48+
49+
### Testing Project
50+
51+
Open `app.component.html` and add the following markup:
52+
53+
```html
54+
<button class="btn btn-primary">Test Button</button>
3155
```
3256

3357
With the application configured, run `ng serve` to run your application in develop mode.
3458
In your browser navigate to the application `localhost:4200`.
35-
Make a change to your application to ensure that the CSS library has been included.
36-
A quick test is to add the following markup to `app.component.html`
59+
Verify the bootstrap styled button appears.
60+
61+
## Using SASS
62+
63+
### Getting Started
64+
65+
Create a new project and navigate into the project
66+
3767
```
38-
<button class="btn btn-primary">Test Button</button>
68+
ng new my-app --style=scss
69+
cd my-app
3970
```
40-
After saving this file, return to the browser to see the bootstrap styled button.
4171

42-
## Using SASS
43-
Open `angular-cli.json` change reference of `styles.css` to `styles.scss` and rename the file accordingly.
72+
### Installing Bootstrap
73+
74+
```sh
75+
# version 3.x
76+
npm install bootstrap-sass --save
77+
78+
# version 4.x
79+
npm install bootstrap@next --save
80+
```
81+
82+
### Configuring Project
4483

4584
Create an empty file `_variables.scss` in `src/`.
4685

47-
In `styles.scss` add the following:
86+
If you are using `bootstrap-sass`, add the following to `_variables.scss`:
4887

88+
```sass
89+
$icon-font-path: '../node_modules/bootstrap-sass/assets/fonts/bootstrap/';
4990
```
50-
@import '_variables';
91+
92+
In `styles.scss` add the following:
93+
94+
```sass
95+
// version 3
96+
@import 'variables';
97+
@import '../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap';
98+
99+
// version 4
100+
@import 'variables';
51101
@import '../node_modules/bootstrap/scss/bootstrap';
52102
```
53103

54-
Open `app.component.html` and add the following markup
55-
```
104+
### Testing Project
105+
106+
Open `app.component.html` and add the following markup:
107+
108+
```html
56109
<button class="btn btn-primary">Test Button</button>
57110
```
111+
58112
With the application configured, run `ng serve` to run your application in develop mode.
59113
In your browser navigate to the application `localhost:4200`.
60114
Verify the bootstrap styled button appears.
61115
To ensure your variables are used open `_variables.scss` and add the following:
116+
117+
```sass
118+
$brand-primary: red;
62119
```
63-
$body-color: red;
64-
```
65-
Return the browser to see the font color changed.
66120

67-
**Note:** When you make changes to `angular-cli.json` you will need to re-start `ng serve` to pick up configuration changes.
121+
Return the browser to see the font color changed.

0 commit comments

Comments
 (0)