DevExtreme React - Icons

Built-In Icon Library

DevExtreme comes with an icon library that provides font icons for all DevExtreme themes. You can use the icons in widgets and in other page elements as they are or customize them.

Available icons are presented below:

Icons in Widgets

Icons can be used in those widgets that have an icon option. For instance, the Button widget has this option on the first level of the configuration object. Icons in the following code samples are taken from the built-in icon library.

  • <template>
  • <dx-button
  • icon="save"
  • text="Save" />
  • </template>
  • <script>
  • import DxButton from 'devextreme-vue/button';
  •  
  • export default {
  • components: {
  • DxButton
  • }
  • }
  • </script>

View Demo

Many default templates provide the icon option as well, the ContextMenu widget's default item template being an example:

  • <template>
  • <dx-context-menu ... >
  • <dx-item text="Zoom In" icon="plus" />
  • <dx-item text="Share" icon="message" />
  • <dx-item text="Download" icon="download" />
  • </dx-context-menu>
  • </template>
  • <script>
  • import { DxContextMenu, DxItem } from 'devextreme-vue/context-menu';
  •  
  • export default {
  • components: {
  • DxContextMenu,
  • DxItem
  • }
  • }
  • </script>

To find a list of widgets that support icons, search for "icon" in the left-hand menu.

Icons in Other HTML Elements

If an HTML element should display a DevExtreme icon, add a dx-icon-IconName class to it. We recommend using inline HTML elements (<i> or <span>).

HTML
  • <i class="dx-icon-email"></i>

You can find icon names in the Built-In Icon Library article.

Customize Icons

Since DevExtreme icons are shipped as an icon font, they can be customized with the same CSS properties that you would use to customize textual content: color, font-size, font-weight, text-align, etc. This is true for icons used in widgets...

  • <template>
  • <dx-button
  • id="saveButton"
  • icon="save"
  • text="Save" />
  • </template>
  • <script>
  • import DxButton from 'devextreme-vue/button';
  •  
  • export default {
  • components: {
  • DxButton
  • }
  • }
  • </script>
  • <style>
  • #saveButton .dx-icon {
  • font-size: 24px;
  • color: blue;
  • }
  • </style>

... and for icons used in any other HTML elements:

HTML
CSS
  • <i class="dx-icon-email dx-icon-custom-style"></i>
  • .dx-icon-custom-style {
  • font-size: 24px;
  • color: blue;
  • }

dx-icon is a CSS class added to icon elements when DevExtreme widgets render them into the DOM. You cannot use another name for it. However, it is not true for icons in other HTML elements. You can use any name for the class in this case, as demonstrated in the previous example.

Custom Images as Icons

The widget's icon option accepts URLs, so you can assign the image's URL to it. However, it is better to encode the image in the Base64 type instead to reduce the amount of transferred data. Search for an image to Base64 converter on the web.

Although Base64 code can be assigned directly to the icon option, we recommend placing it in the CSS because of its length. Add the following CSS rule to your stylesheet:

CSS
  • .dx-icon-customicon { // in Angular apps, add ::ng-deep before
  • background-image: url(data:image/png;base64,... LONG BASE64 CODE IS HERE ...);
  • background-repeat: no-repeat;
  • background-position: 0px 0px;
  • }

customicon here is the icon's name that you should assign to the widget's icon option.

In addition, you can provide a specific icon variant for different states of a widget element. In the following code, a special icon is provided for selected tabs:

CSS
  • .dx-tab-selected .dx-icon-customicon {
  • background-image: url(data:image/png;base64,... LONG BASE64 CODE GOES HERE ...);
  • background-repeat: no-repeat;
  • background-position: 0px 0px;
  • }

Classes like dx-tab-selected from the previous example are not documented. Inspect CSS rules to find out which classes are added to the widget element you are customizing.

External Icon Libraries

Icons in widgets are inserted into the DOM as <i> elements. When you set a widget's icon option, its value is used to form the class attribute of the <i> element. For instance, the code below ...

  • icon: "home"

... renders into the DOM as follows:

HTML
  • <i class="dx-icon dx-icon-home"></i>

This allows DevExtreme widgets to support icons from external icon libraries, provided that they too should be specified in the class attribute.

Font Awesome, Glyphicons, and Ionicons are examples of such libraries. Follow the installation tutorial for the library you want to use and set the icon option as follows:

  • <template>
  • <dx-button ...
  • icon="fas fa-home" <!-- Font Awesome 5 -->
  • icon="fa fa-home" <!-- Font Awesome 4 -->
  • icon="glyphicon glyphicon-home" <!-- Glyphicons -->
  • icon="ion ion-home" /> <!-- Ionicons -->
  • </template>
  • <script>
  • import DxButton from 'devextreme-vue/button';
  •  
  • export default {
  • components: {
  • DxButton
  • }
  • }
  • </script>