Angular component default style css display block

My pull-request has been merged.

With the upcoming release of Angular CLI v9.1.0 a new option is going to be available:

--displayBlock=true|false

Docs: https://next.angular.io/cli/generate#component

For the impatient: It’s available right now in v9.1.0-next.0

When using the CLI:

ng generate component dashboard --displayBlock=true

Settting a default value in angular.json:

...
"projectType": "application",
"schematics": {
    "@schematics/angular:component": {
      "displayBlock": true
   }
 }
...

From now on any generated component, be it with the css inlined or not, will contain the css:

:host { display: block; }

More detailed information is available here: https://blog.rryter.ch/2020/01/19/angular-cli-generating-block-components-by-default/

Leave a Comment

tech