title: Theme customization category: examples-framework
The @ckeditor/ckeditor5-theme-lark is the default theme of CKEditor 5. Lark is modular, BEM–friendly and built in SASS.
Although it has been designed with versatility and the most common editor use–cases in mind, some integrations may require adjustments to make it match the style guidelines of the ecosystem. This kind of customization can be done in two different ways, which can also be used together if needed:
.scss file and overriding the CSS rules, which increases the size of the build.{@snippet examples/theme-lark}
CKEditor 5 is bundled using webpack and it handles the importing and processing of the styles using the loaders. Its configuration can be found in the webpack.config.js file.
To learn more about building CKEditor, check out the {@link builds/guides/development/custom-builds official guide}.
The entire process of building and managing the styles boils down to three steps:
Collecting: Each JavaScript file in the project can import multiple .scss files using the ES6 import directive. Imported files are handled by the CSS Loader.
import '../theme/theme.scss';
class AnyEditorClass {
...
}
// Contents of theme.scss.
$color: red;
.ck-editor {
color: $color;
}
Compiling: The SASS Loader compiles .scss files from SASS to CSS. Each file is compiled asynchronously, in a separate SASS thread.
.ck-editor {
color: $color; --> color: red;
}
Loading: Finally the Style loader loads the output CSS along with the ckeditor.js file into a <style> element in the <head> section of the web page.
<head>
<style type="text/css">
.ck-editor {
color: red;
}
</style>
</head>
Having {@link builds/guides/development/custom-builds#Forking-an-existing-build cloned} an existing build of CKEditor for a quick start, let's take a look on the specific definitions in the webpack.config.js.
module: {
rules: [
...
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
}
]
}
Each single SASS file is compiled in a separate thread, so to override default variables (defined with !default) across the theme, new values must be imported/declared at the very beginning of each single SASS file's compilation process. SASS Loader offers the data option to do this.
Check out the [colors helper](https://github.com/ckeditor/ckeditor5-theme-lark/blob/master/theme/helpers/_colors.scss) for the full list of customizable colors. You can also browse [other helpers](https://github.com/ckeditor/ckeditor5-theme-lark/tree/master/theme/helpers) to learn about other useful SASS variables.
Let's @import a custom.scss file located in the root of the repository containing all custom variables.
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
data: `@import 'custom.scss';`
}
}
]
Using the full potential of the SASS variables, the customization will make the theme dark, with slightly bigger text and more rounded corners.
// Overrides the border-radius setting in the theme.
$ck-border-radius: 4px;
// Overrides the default font size in the theme.
$ck-font-size-base: 14px;
// Helper variables to avoid duplication in $ck-colors.
$custom-background: #4A494B;
$custom-foreground: #3a393d;
$custom-border: #383738;
$custom-white: #fff;
// Colors used by the ck-color() mixin across the theme.
$ck-colors: (
// Overrides the default focus color used by the ck-focus-ring() mixin.
'border-focus': #48a3f5,
// Overrides the default text color in the theme.
'text': #fafafa,
// Overrides the default shadow colors in the theme.
'shadow-drop': rgba( 0, 0, 0, .2 ),
'shadow-inner': rgba( 0, 0, 0, .1 ),
// Overrides the default .ck-button class colors.
'button-default-background': $custom-background,
'button-default-border': $custom-border,
'button-on-background': $custom-foreground,
'button-on-border': $custom-border,
'button-action-background': #1ABC9C,
'button-action-border': #49d2b7,
'button-action-text': $custom-white,
// Overrides the default .ck-dropdown class colors.
'dropdown-panel-background': $custom-background,
'dropdown-panel-border': $custom-foreground,
'dropdown-symbol': #f1f1f1,
// Overrides the default .ck-input class colors.
'input-background': $custom-foreground,
'input-border': #6b6970,
'input-text': #fafafa,
// Overrides the default .ck-list class colors.
'list-background': $custom-background,
'list-item-background-hover': $custom-foreground,
'list-item-background-active': #1A8BF1,
'list-item-text-active': $custom-white,
// Overrides the default .ck-balloon-panel class colors.
'panel-background': $custom-background,
'panel-border': $custom-border,
// Overrides the default .ck-toolbar class colors.
'toolbar-background': $custom-foreground,
'toolbar-border': $custom-border,
// Overrides the default .ck-tooltip class colors.
'tooltip-background': #212025,
'tooltip-text': #eee,
// Overrides the default colors used by the editor.
'editor-border': $custom-background,
'editor-toolbar-background': $custom-background,
'editor-toolbar-button-background': $custom-background,
'editor-dropdown-background': #535254,
// Overrides the default colors used by ckeditor5-image package.
'image-caption-background': #f7f7f7,
'image-caption-text': #333,
// Overrides the default colors used by ckeditor5-widget package.
'widget-border-blurred': #ddd,
'widget-border-hover': #FFD25C,
'widget-editable-focused-background': $custom-white
);
Now let's build the editor using npm run build-ckeditor and see the results. From now on, the editor should always use customized styles.