How to change the CSS

It is important to know how our web components look, control details such as fonts, layout, colors, backgrounds, margins, etc.

Using Kendo UI Angular is easy to choose a theme like :

  • Kendo UI Default theme

  • Kendo UI Bootstrap theme

  • Kendo UI Material theme

  • To start using the Default or Material theme, install it through NPM.

    npm install --save @progress/kendo-theme-default
  • For the Bootstrap theme, which depends on the Bootstrap framework, install the version of the bootstrap framework specified as a peer dependency.

  • After the theme package is installed, reference it in your project.

This steps have been taken from kendo Styling Guide here you can find the kendo styling documentation.

There are some ways to take even more control over components style

Global styles in WinformsComponent

Applying global CSS to our project is easy, we just have to use a general document styling to apply CSS styles to our components.

In our angular project we are talking about the styles.scss or jQueryStyles.scss files, these files allows users to add global styles and supports CSS imports.

Those global styles and further must be added inside angular-cli.json.

"styles": [
"./src/style/styles.css",
"./src/style/jQueryStyles.css",
"./node_modules/primeng/resources/themes/omega/theme.css",
"./node_modules/font-awesome/css/font-awesome.min.css"
]

These will be loaded exactly as if you had added them in a <link> tag inside html file.

Styles in Samples

Aplying Classes

We implement a special behavior on each component using html class attribute to add classes in the internal component.

<wm-datetimepicker [model]="model.datetimepicker1" class="datetimepicker1"></wm-datetimepicker>

With this we can take control of any component that is inside a form just using the css file generated by the migration tool like this:

.Samples_frmControls .datetimepicker1{
width: 300px;
height: 30px;
position: absolute;
top: 88px;
left: calc(50% + 50px);
}

The special behavior is that the component declaration does not use the css class, actually, the content rendered is whom uses the css class and the class is removed from component declaration.

For example, the following component declaration has the buttonLoading css class:

<wm-button [model]="model.buttonLoading" class="buttonLoading" (Click)="loadingEvent($event)"></wm-button>

however when the component is rendered in the browser its declaration does not contain the buttonLoading class, but the content displayed inside of the declaration has applied the class successfully.

<wm-button class="" _nghost-c7="" ng-reflect-class="buttonLoading" ng-reflect-model="[object Object]">
<button _ngcontent-c7="" class="buttonLoading k-button" kendobutton="" wmcontrols="" ng-reflect-klass="k-primary" ng-reflect-ng-class="buttonLoading" dir="ltr" title="">Show Loading</button>
</wm-button>

Note

If you want to add a specific class to container element you can do it using ngClass, for example if you want to add a class in the outer definition of the component you should use ngClass="buttonSpecialClass" and this class will be applied in the component declaration.

*The class included in the ngClass must be written as string literal with single quotes ''.

<wm-button [model]="model.buttonLoading" class="buttonLoading" ngClass='buttonSpecialClass' (Click)="loadingEvent($event)"></wm-button>

And the buttonSpecialClass defined in ngClass will appear on the component declaration:

<wm-button class="buttonSpecialClass" _nghost-c7="" ng-reflect-class="buttonLoading" ng-reflect-model="[object Object]">
<button _ngcontent-c7="" class="buttonLoading k-button" kendobutton="" wmcontrols="" ng-reflect-klass="k-primary" ng-reflect-ng-class="buttonLoading" dir="ltr" title="">Show Loading</button>
</wm-button>

Local styles on WinformsComponent

On every single component that is generated like this:

ng generate component my-new-component

a scss file will be generated, here you should be able to modify the style of any component locally.

Its important to have in mind that these properties may be affected by any global style change