Customization
Icons
DHTMLX Ribbon uses the icons of the DHTMLX library by default. However, you can use any other icon font pack, if necessary. For this, you need to include the desired icon font on a page and apply icons for Ribbon controls.
For example, you can use the Material Design icon pack by including link to its CDN after the source files of DHTMLX Ribbon as follows:
<script type="text/javascript" src="../../codebase/ribbon.js"></script>
<link rel="stylesheet" href="../../codebase/ribbon.css">
<link href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css?v=6.4.4"
media="all" rel="stylesheet" type="text/css">
Then you can use the name of the icon as the value of the icon property in the object with the control parameters for ribbon:
const data = [
{
type: "block",
"items": [
{
type: "block",
"items": [
{
value: "New",
icon: "mdi mdi-file-outline",
size: "auto",
}
]
},
{
type: "block",
direction: "col",
"items": [
{
value: "Add",
icon: "mdi mdi-plus",
size: "small",
},
{
value: "Remove",
icon: "mdi mdi-minus",
size: "small",
}
]
}
]
}
];
Related sample: Ribbon. Custom icons
You can use the Font Awesome icon pack by including link to its CDN in the same way.
Styling
There is a possibility to make changes in the look and feel of a ribbon.
Related sample: Ribbon. Styling (custom CSS)
For this you need to take the following steps:
- add a new CSS class(es) with desired settings in the <style> section of your HTML page or in your file with styles (don't forget to include your file on the page in this case)
<style>
.my-first-class {
/*some styles*/
}
.my-second-class {
/*some styles*/
}
</style>
- specify the name of the created CSS class (or names of classes separated by spaces) as the value of the css property in the Ribbon configuration:
const ribbon = new dhx.Ribbon("ribbon_container", {
css:"my_first_class my_second_class"
});
For example:
<style>
.custom {
--dhx-background-secondary: var(--dhx-color-white);
--dhx-color-primary-light-hover: #aefafa;
--dhx-color-primary-light-active: #118d8d;
}
</style>
<script>
const ribbon = new dhx.Ribbon("ribbon_container", {
css: "custom dhx_widget--bordered"
});
ribbon.data.parse(data);
</script>