Can I modify, the default toolbar icon with custom text or icon?
Im using classic editor in ckeditor 5, Can i modify the default toolbar icons with custom icons/text.
Existing:
Expected:

Hi! It's possible to make such changes. Please, take a look at our ButtonView documentation.
If you want to use a custom icon, pass to the set() method icon property with a path to the icon. For using text instead of an icon, user withText: true property.
Here is an example - to change the Font size icon, modify a path to it in the following line in the feature code - https://github.com/ckeditor/ckeditor5-font/blob/master/src/fontsize/fontsizeui.js#L18.
If you want to use a text, in the same file modify code as follows:
dropdownView.buttonView.set( {
label: t( 'Font Size' ),
// icon: fontSizeIcon, --> remove icon
tooltip: true,
withText: true // --> use text instead of icon
} );
@Mgsy I could apply the solution above if i created a custom plugin, but what if i want to modify default toolbar styles. Here, I have used one of the default toolbar menu - fontSize. Is there a way to override default toolbar styles?
ClassicEditor.create(editor, {
fontSize: { options: [9, 10, 11, 12, 14, 19, 21] },
toolbar: [
"fontSize",
"bold",
"italic",
"underline",
"bulletedList",
"numberedList",
"link"
]
});
ClassicEditor.create(editor, { fontSize: { options: [9, 10, 11, 12, 14, 19, 21] }, toolbar: [ "fontSize", "bold", "italic", "underline", "bulletedList", "numberedList", "link" ] });
I have same issue and nowhere can i find a solution.
I'm looking for a solution too +1 👍
I manage to create an outside action that will allow you to create a custom toolbar This is just JS
BalloonEditor.create(document.querySelector("#editor"))
.then(editor => {
const documentSelection = editor.model.document.selection;
document.getElementById('bold').addEventListener('click', e => {
e.preventDefault();
e.stopPropagation();
editor.execute( 'bold' );
document.querySelector("#editor").focus();
editor.model.change( writer => {
writer.setSelection( documentSelection, 'end' );
} );
})
window.editor = editor;
})
.catch(err => {
console.error(err.stack);
});
But I look 👀for a configurable solution ?! @Mgsy
@Mgsy Any updates on this problem? I have the same issue. I want to remove the fontSize Icon and just show font-sizes itself on the dropdown. But I can't seem to find a way to remove the icon without needing to create a completely separate custom plugin for the same.
@Mgsy Do you help me? I cannot find a normal solution of my issue - disable text in default 'headers' button.
Found this on another question - https://ckeditor.com/docs/ckeditor5/latest/builds/guides/faq.html#how-to-customize-the-ckeditor-5-icons https://github.com/ckeditor/ckeditor5/issues/7810 Hope this is what you are looking for.
@premsanth-rajamani @isetpro @castroCrea @atzork @zeeskhan1990
Found the solution:
const specialCharactersButtonView = editor.ui.view.toolbar.items._items.find(item => item.label === 'Special characters')
if (specialCharactersButtonView) {
specialCharactersButtonView.icon = '<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="26.000000pt" height="25.000000pt" viewBox="0 0 26.000000 25.000000" preserveAspectRatio="xMidYMid meet"><g transform="translate(0.000000,25.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none"><path d="M68 234 c-60 -32 -78 -129 -33 -183 67 -79 186 -52 215 48 28 100 -88 187 -182 135z m120 -17 c30 -14 52 -56 52 -98 0 -43 -56 -99 -99 -99 -99 0 -156 115 -88 178 43 41 81 46 135 19z"/><path d="M80 150 c0 -11 5 -20 10 -20 6 0 10 9 10 20 0 11 -4 20 -10 20 -5 0 -10 -9 -10 -20z"/><path d="M166 163 c-12 -12 -6 -33 9 -33 8 0 15 6 15 14 0 17 -14 28 -24 19z"/><path d="M75 100 c-10 -16 14 -49 40 -56 32 -8 75 19 75 46 0 18 -7 20 -54 20 -30 0 -58 -4 -61 -10z m105 -10 c0 -5 -22 -10 -50 -10 -27 0 -50 5 -50 10 0 6 23 10 50 10 28 0 50 -4 50 -10z"/></g></svg>'
}