Adds toolbar and context buttons for inline text and background color. Applies color as a <span> style on the selected text, or maps colors to CSS classes when classes is set.
Select text, click Text color in the toolbar (before More), and pick a color from the Text color or Background tab. Use Remove color to clear formatting.
<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/font-color/font-color.js"></script>
const app = Redactor('#entry', {
plugins: ['fontColor']
});
boolean)
truetrue, shows a manual hex input in the color picker.object | string[] | false)
falsefalse uses the editor-wide colors option.string[] | false)
false<span>.string)
Redactor('#entry', {
plugins: ['fontColor'],
fontColor: {
colors: ['#000000', '#e03131', '#1971c2', '#37b24d']
}
});
Class-based mode:
Redactor('#entry', {
plugins: ['fontColor'],
fontColor: {
classes: ['text-red', 'text-blue', 'text-green']
}
});
en: {
fontColor: {
title: 'Text color',
remove: 'Remove color',
'text-color': 'Text color',
background: 'Background'
}
}
This plugin does not emit events.
Applies an inline color to the current selection and closes the dropdown.
Parameters:
color (string) — CSS color value (for example #e03131).target (string, optional) — 'background' for background color; omit or use any other value for text color.app.fontColor.set({ color: '#e03131' });
app.fontColor.set({ color: '#fff3bf', target: 'background' });
Clears inline text or background color from the selection and closes the dropdown.
Parameters:
target (string, optional) — 'background' to clear background color only.app.fontColor.remove();
app.fontColor.remove({ target: 'background' });
Clears inline background color from the selection. Same as remove({ target: 'background' }).
app.fontColor.removeBackground();