Setting Text and Background Color Documentation
The optional Text and Background Color feature is provided through the Color Button plugin which by default is available in the Full distribution.
When the plugin is enabled, the Remove Format plugin.
and buttons are automatically added to the toolbar. You can use them to add some color to your content. If you want to quickly remove colors from your document, use the button provided by theMore Colors Option and Color Dialog
You can also add an optional Color Dialog plugin which provides the More Colors option and a user-friendly way to select the desired color through a dedicated dialog window. The editor instance below includes both features. Notice how the picked colors are saved in the color history row below the default palette for easy reuse.
Color History and Suggestions
Whenever you open any document you have worked on before, you can quickly reuse text and background colors that are present in the content. Thanks to Color History feature
introduced in CKEditor 4.15
version, editor finds all colors during initialization and adds them as additional color history rows below the default palette. Additionally, every
new color used is also added to the color history rows for even easier reuse. You can read more about this feature in the
Color History documentation.
Custom Color List
Allowing your users to use any colors they wish might lead to undesired results, i.e. joyfully colorful content
that will make your page look like it was created in the early 1990s. You can prevent this situation by customizing the
color list to only include a limited number of colors that match your website style. The editor instance below
uses the config.colorButton_colors
option to trim down the color list to a selected few.
Additionally, since CKEditor 4.5.8 you can also disable the "Automatic" option by setting the config.colorButton_enableAutomatic
option to false
. The editor instance below includes customizations.
Related Features
- Styling and Formatting – Copying Text Formatting
- Styling and Formatting – Removing Text Formatting
- Styling and Formatting – Basic Text Styles: Bold, Italic and More
- Styling and Formatting – Applying Styles to Editor Content
- Styling and Formatting – Applying Block-Level Text Formats
Get Sample Source Code
- Text and background color with Color Dialog
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <title>Text and background color with Color Dialog</title> <script src="https://cdn.ckeditor.com/4.25.0-lts/standard-all/ckeditor.js"></script> </head> <body> <textarea cols="80" id="editor1" name="editor1" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="https://ckeditor.com/">CKEditor</a>.</p></textarea> <script> CKEDITOR.replace('editor1', { height: 250, extraPlugins: 'colorbutton,colordialog', removeButtons: 'PasteFromWord' }); </script> </body> </html>
- Custom text and background colors
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <title>Custom text and background colors</title> <script src="https://cdn.ckeditor.com/4.25.0-lts/standard-all/ckeditor.js"></script> </head> <body> <textarea cols="80" id="editor2" name="editor2" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="https://ckeditor.com/">CKEditor</a>.</p></textarea> <script> CKEDITOR.replace('editor2', { height: 250, extraPlugins: 'colorbutton', removeButtons: 'PasteFromWord' }); </script> </body> </html>