Icons can be nested into all components and their items. You can put an icon on the Toolbar in the form of buttons, decorate Tabbar tabs and Accordion panes as well as List and DataView items with them, etc.
Icons can be initialized in the following ways:
Check the related sample to see the list of available default icons:
Related sample: Icons Cheatsheet
Webix provides two predefined sets of icons depending on the used skin:
1. Webix Awesome Icons for Flat, Compact and Contrast skins - based on Font Awesome 5 collection
2. Webix Material Icons for Material, Mini, Willow, and Dark skins - based on Material Design Icons collection
The default Webix icons can be set in two ways:
// using a default icon
{
view:"icon",
icon:"wxi-pencil" }
<span class='webix_icon wxi-pencil'></span>
You can also use any custom font icon pack in your Webix-based application. For this, you need to:
1. include the desired font icon pack into your HTML page;
2. set the full name of the icon you want to use:
// using a Font Awesome icon
{ view:"icon", icon:"fas fa-envelope"}
// using a Material Design icon
{ view:"icon", icon:"mdi mdi-email"}
For example, you can use:
A UI-related icon looks like a button with a border. A text label isn't supposed for this icon type.
// using a default icon
{ view:"icon", icon:"wxi-pencil"}
// using a Font Awesome icon
{ view:"icon", icon:"fas fa-pencil"}
// using a Material Design icon
{ view:"icon", icon:"mdi mdi-pencil"}
The value of the icon property is the name of the needed icon.
type:"icon" |
|
type:"iconTop" |
// using a default icon
{ view:"button", type:"icon", icon:"wxi-pencil", label:"Edit" }
// using a Font Awesome icon
{ view:"button", type:"icon", icon:"fas fa-pencil", label:"Edit"}
// using a Material Design icon
{ view:"button", type:"icon", icon:"mdi mdi-pencil", label:"Edit"}
This method of icon initialization fits the widgets and items that normally have not buttons, but: tabs (they are buttons themselves), panes, list and dataview items, datatable cells. In this case, icons are not buttons and used as decoration.
Possible CSS classes are as follows:
For custom icons use 'webix_icon full icon name' and 'webix_input_icon full icon name', correspondingly.
Both classes include an icon name that can be checked in the list of default icons or at the site of the used font icon pack.
Multiview tabs
{ view:"tabbar", options:[
// a default icon
{ value:"pencil", label:"Edit", css:"webix_icon wxi-pencil"}
// a Material Design icon
{ value:"mail", label:"Mail", css:"webix_icon mdi mdi-email"},
// a Font Awesome icon
{ value:"users", label:"User", css:"webix_icon fas fa-user"}
]}
An additional HTML element with an 'icon' class can be added to the text value of any widget's item:
AccordionItem pane with an icon
{ header:"<span class='webix_icon wxi-pencil'></span>Edit"}
List item with an icon
{ template:"<span class='webix_icon wxi-#icon#'></span> #name#"}
Here the icon's name is in the hash signs, since it comes from a dataset, e.g. in JSON it looks like:
var data=[
{id:1, name:"item1", icon:"wxi-pencil"},
{id:2, name:"item2", icon:"wxi-trash"}
]
The default icons that are used for various controls can be changed to custom ones in several ways.
If you'd like to use a different icon instead of the default one, specify its name as a value of the icon property:
{view:"richselect", label: "Other", options:options, icon:"mdi mdi-arrow-down"}
As a result, the default RichSelect icon, "wxi-menu-down", is replaced with the "mdi mdi-arrow-down" icon from the Material Design collection.
To set a custom icon that you can provide as a background image, write a new CSS rule that redefines the default one. Nothing is changed in the control configuration:
{view:"combo", label: "Fruit", options:[...] }
The same as RichSelect, the Combo control uses the "wxi-menu-down" icon, the CSS of which should be modified:
.webix_input_icon.wxi-menu-down:before{
content:""; // removes the default icon
background-image: url("search.png");
width:20px;
height:20px;
display:block;
}
As a result, the "wxi-angle-down" icon is redefined by the custom icon - "search.png".
Related sample: Styling Combo Icons
If you want to style one combo on the page while leaving another one unchanged, define a separate css class for the one in question:
{view:"combo", label: "Fruit", options:[...], css:"custom" }
Then the necessary CSS will look like this:
.custom .webix_input_icon.wxi-menu-down:before{
// attributes of the custom CSS class
}
Styling of widgets is described in detail in the corresponding article of the documentation.
Back to top