Icons
The Kendo UI suite for Angular delivers more than 400 integrated font icons for its components.
What Are Icon Fonts
Icon fonts are fonts which contain vector glyphs instead of letters and numbers. You can style them with CSS by using all styling properties that can be applied to a regular text in a modern browser.
Why Use Font Icons
Font icons in user interfaces (UI) naturally succeed the somehow outdated icon sprites.
Font icons demonstrate significant benefits such as:
- Improved scalability—Icon sprites are bitmap raster images and do not scale well. Font icons use vector graphics, look perfect on retina displays, and make scaling as easy as setting the
font-size
style. - Improved design capabilities—You can easily apply CSS effects on the fly by setting text color, shadow, or even styles for interaction states, such as
:hover
. - Improved browser support—Font icons are supported by all modern browsers.
- Significantly fewer HTTP requests, compared to separate icons.
- Reduced file size—A 100KB file contains approximately 500 vector icons.
Basic Usage
To use the Kendo UI font icons:
-
Load a Kendo UI theme in your project.
-
Add an empty
<span>
element that will hold the font icon. -
Assign a
k-icon
CSS class that is followed by a predefined class from the list of font icons to an HTML tag. For example:<span class="k-icon k-i-calendar"></span>
.
Using Unicode Characters
Even though the web icon font comes with a set of predefined CSS classes, you might need to use the icons with a custom CSS class name. To achieve this, set a :before
pseudo content value for the relevant icon.
<span class="k-icon my-custom-icon-class"></span>
<style>
.my-custom-icon-class:before {
content: "\e13a"; /* Adds a glyph using the Unicode character number */
}
</style>
If you use the styles
property in the metadata of the component, you need to escape the content by double-backslashing it.
selector: 'my-app',
styles: [`
.k-icon.my-custom-icon-class:before {
content: "\\e13a";
}
`],
template: `
<span class="k-icon my-custom-icon-class"></span>
`
})
class AppComponent {
}
({
Making Visual Adjustments
You can modify the appearance of each icon by using:
Sizes
The default size of all Kendo UI icons is 16 px (Font-size: 16 px; Width: 16 px; Height: 16 px). However, Kendo UI provides the following predefined sizes for icons:
xsmall
—Font-size: 12 px; Width: 12 px; Height: 12 px.small
—Font-size: 14 px; Width: 14 px; Height: 14 px.medium
—Font-size: 16 px; Width: 16 px; Height: 16 px.large
—Font-size: 20 px; Width: 20 px; Height: 20 px.xlarge
—Font-size: 24 px; Width: 24 px; Height: 24 px.xxlarge
—Font-size: 32 px; Width: 32 px; Height: 32 px.xxxlarge
—Font-size: 48 px; Width: 48 px; Height: 48 px.
You can set each of them by using the respective class:
k-icon-xs
k-icon-sm
k-icon-md
k-icon-lg
k-icon-xl
k-icon-xxl
k-icon-xxxl
<span class="k-icon k-i-gear k-icon-xs"></span>
<span class="k-icon k-i-gear k-icon-md"></span>
<span class="k-icon k-i-gear k-icon-xl"></span>
For font icons, you can apply any custom size by using the CSS font-size
property.
<span class="k-icon k-i-gear k-icon-24"></span>
<style>
.k-icon-24 {
font-size: 24px; /* Sets icon size to 24 px */
}
</style>
For SVG icons, you can change the size with the width
and height
CSS properties.
<span class="k-svg-icon k-svg-i-gear k-icon-24"></span>
<style>
.k-icon-24 {
width: 24px;
height: 24px;
}
</style>
Colors
Kendo UI provides the following predefined colors:
primary
—Applies coloring based on primary theme color.secondary
—Applies coloring based on secondary theme color.tertiary
— Applies coloring based on tertiary theme color.info
—Applies coloring based on info theme color.success
— Applies coloring based on success theme color.warning
— Applies coloring based on warning theme color.error
— Applies coloring based on error theme color.dark
— Applies coloring based on dark theme color.light
— Applies coloring based on light theme color.inverse
— Applies coloring based on inverse theme color.
You can set each of them by using the respective CSS class:
k-color-primary
k-color-secondary
k-color-tertiary
k-color-info
k-color-success
k-color-warning
k-color-error
k-color-dark
k-color-light
k-color-inverse
.
<span class="k-icon k-i-gear k-color-primary"></span>
<span class="k-icon k-i-gear k-color-info"></span>
<span class="k-icon k-i-gear k-color-light"></span>
You can also apply any custom color by using the CSS color
property.
<span class="k-icon k-i-gear" style="color: blue;"></span>
Flipping and Rotating
To better accommodate an icon in your application, flip it horizontally, vertically, or in both directions by using the k-flip-h
and k-flip-v
predefined CSS classes.
<span class="k-icon k-i-pencil k-flip-h"></span>
<span class="k-icon k-i-pencil k-flip-v"></span>
<span class="k-icon k-i-pencil k-flip-h k-flip-v"></span>
You can also rotate the icon with the help of the following predefined CSS classes:
k-rotate-0
—Rotates an icon 0°.k-rotate-45
—Rotates an icon 45°.k-rotate-90
—Rotates an icon 90°.k-rotate-135
—Rotates an icon 135°.k-rotate-180
—Rotates an icon 180°.k-rotate-225
—Rotates an icon 225°.k-rotate-270
—Rotates an icon 270°.k-rotate-315
—Rotates an icon 315°.
<span class="k-icon k-i-pencil k-rotate-90"></span>
List of Font Icons
For the full list of the available predefined Kendo UI icons, refer to this section.