You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,20 +29,37 @@ Assuming we're starting with a new @angular/cli project:
29
29
```shell
30
30
$ npx @angular/cli new my-project --style=scss
31
31
$ cd my-project
32
-
$ npm i --save carbon-components-angular @carbon/styles
32
+
$ npm i --save carbon-components-angular @carbon/styles @carbon/icons
33
33
```
34
34
35
-
Then we need to include carbon-components in `src/styles.scss`:
35
+
Next, we need to include carbon styles in `src/styles.scss`:
36
36
37
37
```scss
38
-
@use"@carbon/styles";
38
+
@use'@carbon/styles/scss/config'with (
39
+
// Use flexbox for grid - stick to CSS Grid or Flexbox
40
+
// CSS Grid has become the default grid system in v11
41
+
$use-flexbox-grid: true,
42
+
// Update path of fonts to exclude tilde, required for vite (Angular 16+)
43
+
$font-path: '@ibm/plex'
44
+
);
45
+
46
+
@use'@carbon/styles';
47
+
48
+
// Import css variables in root
49
+
html {
50
+
@includestyles.theme(styles.$white);
51
+
}
39
52
```
40
53
41
-
> *Note:* For offline usage we'll need to set `$font-path: '~carbon-components/src/globals/fonts';` at the very top of our `src/styles.scss`. This will copy the fonts to our `dist` folder upon successful build. If you like the fonts to be a part of your `assets` folder and not pollute the `dist` folder then copy the fonts from `node_modules/carbon-components/src/globals/fonts` into our app's `src/assets/fonts` folder and add `$font-path: '/assets/fonts/';` at the very top of our `src/styles.scss`.
54
+
Then we need to declare `@carbon/icons` as a module by creating a `module.d.ts` file (or use any existing declaration file - has `.d.ts` suffix) in your src directory:
55
+
56
+
```ts
57
+
declaremodule'@carbon/icons/*';
58
+
```
42
59
43
60
That's it! Now we can run `npm start` and start building out our application!
44
61
45
-
> *Note:* This isn't the only way to bootstrap a `carbon-components-angular` application, but the combination of `@angular/cli` and the `carbon-components` scss is our recommended setup.
62
+
> *Note:* This isn't the only way to bootstrap a `carbon-components-angular` application, but the combination of `@angular/cli` and the `@carbon/styles` scss is our recommended setup.
0 commit comments