|
| 1 | +--- |
| 2 | +title: Stylization |
| 3 | +sidebar_label: Stylization |
| 4 | +description: You can learn about the stylization in the documentation of the DHTMLX JavaScript RichText library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX RichText. |
| 5 | +--- |
| 6 | + |
| 7 | +# Stylization |
| 8 | + |
| 9 | +You can fully customize the appearance of DHTMLX RichText by overriding CSS variables and applying custom styles to specific parts of the widget. |
| 10 | + |
| 11 | +This guide shows how to apply a **dark theme** and use available class names to style the editor’s menubar, toolbar, popup, and content area. |
| 12 | + |
| 13 | +## Default structure and class names |
| 14 | + |
| 15 | +RichText uses the following core classes to structure its UI: |
| 16 | + |
| 17 | +| Class name | Description | |
| 18 | +|------------------------|---------------------------------------------| |
| 19 | +| `.wx-richtext` | Root container of the RichText widget | |
| 20 | +| `.wx-richtext-menu` | Toolbar and menu area | |
| 21 | +| `.wx-richtext-popup` | Popup panels (e.g., color picker, font size)| |
| 22 | +| `.wx-richtext-editor` | Main editable content area | |
| 23 | + |
| 24 | +You can use these classes in your custom CSS selectors to override the appearance of the RichText editor. |
| 25 | + |
| 26 | +## Overriding default styles |
| 27 | + |
| 28 | +You can override RichText's default colors by redefining CSS variables on the `#root` container or on specific sub-elements: |
| 29 | + |
| 30 | +```html |
| 31 | +<div id="root" style="width: 100%; height: 100%;"></div> |
| 32 | + |
| 33 | +<style> |
| 34 | + #root, |
| 35 | + .wx-richtext-menu { |
| 36 | + --wx-background: #404151; |
| 37 | + --wx-background-alt: #212329; |
| 38 | + --wx-color-primary: #14B195; |
| 39 | + --wx-color-font: #FFFFFF; |
| 40 | + --wx-border: 1px solid #6B6C79; |
| 41 | + --wx-color-secondary-hover: rgba(20, 177, 149, 0.12); |
| 42 | + --wx-button-active: rgba(20, 177, 149, 0.22); |
| 43 | + --wx-icon-color: var(--wx-color-font); |
| 44 | + --wx-color-font-alt: #9FA1AE; |
| 45 | + --wx-color-font-disabled: #9FA1AE; |
| 46 | + --wx-popup-border: var(--wx-border); |
| 47 | +
|
| 48 | + color-scheme: dark; |
| 49 | + } |
| 50 | +
|
| 51 | + .wx-richtext-menu { |
| 52 | + border: var(--wx-border); |
| 53 | + } |
| 54 | +</style> |
| 55 | +``` |
| 56 | + |
| 57 | +:::note |
| 58 | +These styles will apply a dark background, adjust button and icon colors, and improve visibility for dark UI themes. |
| 59 | +::: |
| 60 | + |
| 61 | +## List of supported CSS variables |
| 62 | + |
| 63 | +| Variable name | Description | |
| 64 | +| ---------------------------- | ------------------------------------ | |
| 65 | +| `--wx-background` | Background color of editor and popup | |
| 66 | +| `--wx-background-alt` | Alternate background (menus and toolbar)| |
| 67 | +| `--wx-color-primary` | Accent color for links | |
| 68 | +| `--wx-color-font` | Main font color (for editor, menubar, and toolbar)| |
| 69 | +| `--wx-color-font-alt` | Alternate font color | |
| 70 | +| `--wx-color-font-disabled` | Disabled text color (for menubar and toolbar elements)| |
| 71 | +| `--wx-border` | Border style used across the editor | |
| 72 | +| `--wx-color-secondary-hover` | Hover state background for buttons within menubar and toolbar | |
| 73 | +| `--wx-button-active` | Active state background for buttons within menubar and toolbar | |
| 74 | +| `--wx-icon-color` | Color used for toolbar icons | |
| 75 | +| `--wx-popup-border` | Border for popup elements | |
| 76 | + |
| 77 | +## Best practices |
| 78 | + |
| 79 | +* Apply custom styles **after** the RichText component is initialized |
| 80 | +* Use `color-scheme: dark` to improve native input styling in dark mode |
| 81 | +* Avoid changing layout-related properties (like `display`, `position`) unless necessary |
| 82 | + |
| 83 | +## Live demo |
| 84 | + |
| 85 | +In this snippet you can see how to apply a custom style to RichText: |
| 86 | + |
| 87 | +<iframe src="https://snippet.dhtmlx.com/q8j4qqq9?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="600"></iframe> |
| 88 | + |
| 89 | +**Related articles:** [Customization](guides/customization.md) |
0 commit comments