Skip to content

Commit 8b92069

Browse files
committed
docs: component-styles guide - inline styles must be CSS
Cannot write them in less, sass, or stylus See CLI issue angular/angular-cli#8472
1 parent ba850b3 commit 8b92069

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

aio/content/guide/component-styles.md

+14-5
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ to a component's `@Component` decorator:
179179
<code-tabs>
180180
<code-pane title="src/app/hero-app.component.ts (CSS in file)" path="component-styles/src/app/hero-app.component.1.ts"></code-pane>
181181
<code-pane title="src/app/hero-app.component.css" path="component-styles/src/app/hero-app.component.1.css"></code-pane>
182-
</code-tabs>
182+
</code-tabs>
183183

184184
<div class="alert is-critical">
185185

@@ -245,7 +245,8 @@ See the [CLI documentation](https://github.com/angular/angular-cli/wiki/stories-
245245

246246
### Non-CSS style files
247247

248-
You can write style files in [sass](http://sass-lang.com/), [less](http://lesscss.org/), or [stylus](http://stylus-lang.com/) and specify those files in the `styleUrls` metadata, e.g.,
248+
If you're building with the CLI,
249+
you can write style files in [sass](http://sass-lang.com/), [less](http://lesscss.org/), or [stylus](http://stylus-lang.com/) and specify those files in the `@Component.styleUrls` metadata with the appropriate extensions (`.scss`, `.less`, `.styl`) as in the following example:
249250

250251
<code-example>
251252
@Component({
@@ -256,10 +257,18 @@ You can write style files in [sass](http://sass-lang.com/), [less](http://lesscs
256257
...
257258
</code-example>
258259

259-
The CLI build process runs the corresponding CSS pre-processors.
260+
The CLI build process runs the pertinent CSS preprocessor.
260261

261-
You can also configure the CLI to default to your preferred CSS pre-processer
262-
as explained in the [CLI documentation](https://github.com/angular/angular-cli/wiki/stories-css-preprocessors).
262+
When generating a component file with `ng generate component`, the CLI emits an empty CSS styles file (`.css`) by default.
263+
You can configure the CLI to default to your preferred CSS preprocessor
264+
as explained in the [CLI documentation](https://github.com/angular/angular-cli/wiki/stories-css-preprocessors
265+
"CSS Preprocessor integration").
266+
267+
<div class="alert is-important">
268+
269+
Style strings added to the `@Component.styles` array _must be written in CSS_ because the CLI cannot apply a preprocessor to inline styles.
270+
271+
</div>
263272

264273
{@a view-encapsulation}
265274

0 commit comments

Comments
 (0)