Create a skin for TinyMCE
Introducing skin creation, less and icon modification.Contribute to this page
This section provides information on how to manually create a new skin to customize the appearance of TinyMCE 5.
The TinyMCE Skin Tool provides an interactive method for designing and creating a skin for TinyMCE, visit: http://skin.tiny.cloud/.
This guide assumes:
- Familiarity with the command line and running simple commands.
- Node.js, Yarn and Gulp are already installed.
- Basic understanding of Less, the CSS preprocessor we use to build the skins. More specifically, read the section about variables.
The CSS that goes with a theme is called a skin. The default skin for TinyMCE 5 is named Oxide and is written in Less, a popular CSS preprocessor. With Oxide we introduced a concept we call the Style API. This API consists of around 300 variables which you use to modify the appearance of TinyMCE. You never touch the underlying CSS. The benefit of this approach is that improvements we make to the CSS and HTML won’t break your custom skin. This also means that if things don’t work as expected, we can provide support and bug fixes, something that was virtually impossible before.
Important: We do not recommend modifying or overriding CSS rules directly.
To set up the skin development environment, begin with the following steps:
git clone) the TinyMCE source code.
Open the terminal and navigate to the folder you just downloaded.
Install dependencies with the command:
Launch the web server to preview the skins using the command:
You should now be able to open a web browser and point it to the url displayed in the terminal, usually
The development environment is set up and ready to work.
If you just need to build the skins without launching a web server, run:
Make sure you have performed the preparation steps above.
modules/oxide/src/less/skins/. There are two folders in this location:
/ui- which is the skins for the editor. The important file here is
/content- which is the skins for the content within the editor.
modules/oxide/src/less/theme/ contains the Less files. At the top of most files you’ll find the available variables that defines the default colors, margins, fonts etc (variables are the strings that starts with an at-character, for example
@background-color). Do not edit these files, instead use them as a reference when creating your skin. We recommend starting with the two files containing global variables:
modules/oxide/src/less/theme/globals/global-variables.less and the toolbar buttons:
The general workflow is that you look inside the less files within the theme folder and copy the variables you like to change into your skin’s
Note: The skin only changes the visual presentation of the UI and not the placement of elements. Placement of elements is done by the TinyMCE UI framework. This framework makes it possible to do complex UI layouts on all browsers without touching any CSS when plugins are created.
- Begin by duplicating the
defaultfolder located in
modules/oxide/src/less/skins/ui/and rename it to the name of your skin.
- Start the development server using the terminal command
yarn oxide-start. If you already have the server running, you need to restart it to make it recognize your new skin using
ctrl-cand then start it again.
- Open the file
- Open any less file located in the theme folder, for example
modules/oxide/src/less/theme/globals/global-variables.lessand copy a variable you like to change, it’s easiest to copy the whole line. Let’s copy the
@background-colorvariable to start with.
- Paste the variable into the
skin.lessfile you opened in step 2. For a striking look, change the variable value to be red, like this:
@background-color: red;. Then save the file.
Your skin.less file should now look like this:
/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ */ @import 'src/less/theme/theme'; // // Place your variables here // @background-color: red;
Switch to the web browser. Select your skin from the Skin menu. It should show a fiery red editor
This is how you skin TinyMCE: copy variables from the files in the theme folder and paste them into your skin file. There are variables for most things, like spacing between toolbar buttons to letter spacing. Simple yet powerful.
Tip: You can change the TinyMCE config in
modules/oxide/src/demo/index.htmlto suit your particular use case.
To update the appearance of the content within the editor, such as headings, quotes, lists, etc… you create a content css. These are located in
- Create a folder in
modules/oxide/src/less/skins/content/and create a
content.lessfile in it. Alternatively, you can duplicate any of the existing content css.
- Start the development server using the terminal command yarn oxide-start. If you already have the server running, you need to restart it to make it recognize your new skin using ctrl-c and then start it again.
- Add the relevant element selectors for the desired use case such as
- Copy the skin and/or content CSS from
modules/oxide/build/skins/to the corresponding folders in your production TinyMCE folder.
- Update the TinyMCE init function with the skin option and/or the content_css option.
For more information on how to specify the location of the skin file, see this section.
For information on adding custom icons, see: Create an icon pack for TinyMCE.
Thanks for the feedback!
Can't find what you're looking for? Let us know.