> Markdown version of [Styling](https://vaadin.com/docs/next/components/rich-text-editor/styling). Section index: [llms.txt](https://vaadin.com/docs/next/components/llms.txt)

# Rich Text Editor Styling

## <a id="style-variants"></a>Style Variants

The following variants are supported:

| Variant     | Description                          | Supported by |
| ----------- | ------------------------------------ | ------------ |
| `compact`   | Makes the toolbar more compact       | Lumo         |
| `no-border` | Removes the border around the editor | Lumo         |

### <a id="compact"></a>Compact

Apply the `compact` style variant to make the toolbar more compact.

**Lit** — `rich-text-editor-theme-compact.ts`

```html
<vaadin-rich-text-editor
  style="height: 400px;"
  theme="compact"
  .value="${this.richText}"
></vaadin-rich-text-editor>
```

**Flow** — `RichTextEditorThemeCompact.java`

```java
RichTextEditor rte = new RichTextEditor();
rte.getStyle().set("max-height", "400px");
String valueAsHtml = DataService.getTemplates().getRichTextHtml();
rte.setValue(valueAsHtml);
rte.addThemeVariants(RichTextEditorVariant.LUMO_COMPACT);
add(rte);
```

**React** — `rich-text-editor-theme-compact.tsx`

```tsx
<RichTextEditor style={{ height: '400px' }} theme="compact" value={richText.value} />
```

### <a id="no-border"></a>No Border

Apply the `no-border` style variant to remove Rich Text Editor’s border. An example of this is when the component is wrapped in a container with its own borders.

**Lit** — `rich-text-editor-theme-no-border.ts`

```html
<vaadin-rich-text-editor
  style="height: 400px;"
  theme="no-border"
  .value="${this.richText}"
></vaadin-rich-text-editor>
```

**Flow** — `RichTextEditorThemeNoBorder.java`

```java
RichTextEditor rte = new RichTextEditor();
rte.getStyle().set("max-height", "400px");
String valueAsHtml = DataService.getTemplates().getRichTextHtml();
rte.setValue(valueAsHtml);
rte.addThemeVariants(RichTextEditorVariant.LUMO_NO_BORDER);
add(rte);
```

**React** — `rich-text-editor-theme-no-border.tsx`

```tsx
<RichTextEditor
  style={{ height: '400px' }}
  theme="no-border"
  value={richText.value}
  onValueChanged={(event) => {
    richText.value = event.detail.value;
  }}
/>
```

## <a id="style-properties"></a>Style Properties

The following style properties can be used in CSS stylesheets to customize the appearance of this component.

To apply values to these properties globally in your application UI, place them in a CSS block using the `html {…​}` selector. See [Component Style Properties](https://vaadin.com/docs/next/styling/styling-components.md#component-style-properties) for more information on style properties.

### <a id="common-properties"></a>Common Properties

| Property                                                 | Supported by |
| -------------------------------------------------------- | ------------ |
| `--vaadin-rich-text-editor-background`                   | Aura, Lumo   |
| `--vaadin-rich-text-editor-content-color`                | Aura, Lumo   |
| `--vaadin-rich-text-editor-content-font-size`            | Aura, Lumo   |
| `--vaadin-rich-text-editor-content-line-height`          | Aura, Lumo   |
| `--vaadin-rich-text-editor-content-padding`              | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-background`           | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-gap`                  | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-padding`              | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-button-background`    | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-button-border-color`  | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-button-border-radius` | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-button-border-width`  | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-button-padding`       | Aura, Lumo   |
| `--vaadin-rich-text-editor-toolbar-button-text-color`    | Aura, Lumo   |

### <a id="overlay-properties"></a>Overlay Properties

| CSS Property                                                   | Supported by |
| -------------------------------------------------------------- | ------------ |
| `--vaadin-rich-text-editor-overlay-gap`                        | Aura         |
| `--vaadin-rich-text-editor-overlay-padding`                    | Aura         |
| `--vaadin-rich-text-editor-overlay-color-option-border-color`  | Aura         |
| `--vaadin-rich-text-editor-overlay-color-option-border-radius` | Aura         |
| `--vaadin-rich-text-editor-overlay-color-option-border-width`  | Aura         |
| `--vaadin-rich-text-editor-overlay-color-option-height`        | Aura         |
| `--vaadin-rich-text-editor-overlay-color-option-width`         | Aura         |

### <a id="animation"></a>Animation (since V25.3)

The overlay has a built-in opening and closing animation, which is disabled until an animation duration is set. The `closed` properties define the state that the overlay animates from when it opens, and to when it closes. The Aura theme sets these properties for some components. Lumo has its own overlay animations, which these properties don’t affect.

While an animation runs, the component has the `opening` or `closing` state attribute, so separate values can be applied to each direction. The backdrop always fades, and only the opacity is animated when the user prefers reduced motion.

| Property                                     | Value syntax                   | Initial value |
| -------------------------------------------- | ------------------------------ | ------------- |
| `--vaadin-overlay-animation-delay`           | `<time>`                       | `0s`          |
| `--vaadin-overlay-animation-duration`        | `<time>`                       | `0s`          |
| `--vaadin-overlay-animation-timing-function` | `<easing-function>`            | `ease`        |
| `--vaadin-overlay-opacity-closed`            | `<number>`                     | `0`           |
| `--vaadin-overlay-scale-closed`              | `<number>` or `<percentage>`   | `1`           |
| `--vaadin-overlay-transform-closed`          | `<transform-list>`             | `none`        |
| `--vaadin-overlay-translate-closed`          | `<length>+` or `<percentage>+` | `0px`         |

> **Note:** These properties are set on the toolbar popup element, `vaadin-rich-text-editor-popup`, not on the `vaadin-rich-text-editor` root element.

## <a id="css-selectors"></a>CSS Selectors

The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the [Styling documentation](https://vaadin.com/docs/next/styling.md) for more details on how to style components.

> **Important: Not for Shadow DOM**
>
> These selectors should be used in `styles.css` or another stylesheet loaded with the `@StyleSheet` annotation or the `@import` CSS rule. **They do not work in the shadow DOM of Vaadin components**, such as in stylesheets in the `components` sub-folder or loaded with the `@CssImport` annotation’s `themeFor` property.

---

- Root element

  `vaadin-rich-text-editor`

### <a id="states"></a>States

- Read-only

  `vaadin-rich-text-editor[readonly]`

- Disabled

  `vaadin-rich-text-editor[disabled]`

- Hovered

  `vaadin-rich-text-editor:hover`

### <a id="toolbar"></a>Toolbar

- Toolbar

  `vaadin-rich-text-editor::part(toolbar)`

- Toolbar button groups

  `vaadin-rich-text-editor::part(toolbar-group)`

- History button group

  `vaadin-rich-text-editor::part(toolbar-group-history)`

- Toolbar buttons

  `vaadin-rich-text-editor::part(toolbar-button)`

- Toolbar button toggled on

  `vaadin-rich-text-editor::part(toolbar-button-pressed)`

- Undo button

  `vaadin-rich-text-editor::part(toolbar-button-undo)`

- Redo button

  `vaadin-rich-text-editor::part(toolbar-button-redo)`

- Emphasis button group

  `vaadin-rich-text-editor::part(toolbar-group-emphasis)`

- Bold button

  `vaadin-rich-text-editor::part(toolbar-button-bold)`

- Italic button

  `vaadin-rich-text-editor::part(toolbar-button-italic)`

- Underline button

  `vaadin-rich-text-editor::part(toolbar-button-underline)`

- Strikeout button

  `vaadin-rich-text-editor::part(toolbar-button-strike)`

- Style button group

  `vaadin-rich-text-editor::part(toolbar-group-style)`

- Text color button

  `vaadin-rich-text-editor::part(toolbar-button-color)`

- Background button

  `vaadin-rich-text-editor::part(toolbar-button-background)`

- Heading button group

  `vaadin-rich-text-editor::part(toolbar-group-heading)`

- H1 button

  `vaadin-rich-text-editor::part(toolbar-button-h1)`

- H2 button

  `vaadin-rich-text-editor::part(toolbar-button-h2)`

- H3 button

  `vaadin-rich-text-editor::part(toolbar-button-h3)`

- Glyph transformation button group

  `vaadin-rich-text-editor::part(toolbar-group-glyph-transformation)`

- Subscript button

  `vaadin-rich-text-editor::part(toolbar-button-subscript)`

- Superscript button

  `vaadin-rich-text-editor::part(toolbar-button-superscript)`

- List button group

  `vaadin-rich-text-editor::part(toolbar-group-list)`

- Ordered list button

  `vaadin-rich-text-editor::part(toolbar-button-list-ordered)`

- Bullet list button

  `vaadin-rich-text-editor::part(toolbar-button-list-bullet)`

- Indentation button group

  `vaadin-rich-text-editor::part(toolbar-group-indent)`

- Decrease indentation button

  `vaadin-rich-text-editor::part(toolbar-button-outdent)`

- Increase indentation button

  `vaadin-rich-text-editor::part(toolbar-button-indent)`

- Alignment button group

  `vaadin-rich-text-editor::part(toolbar-group-alignment)`

- Align left button

  `vaadin-rich-text-editor::part(toolbar-button-align-left)`

- Align center button

  `vaadin-rich-text-editor::part(toolbar-button-align-center)`

- Align right button

  `vaadin-rich-text-editor::part(toolbar-button-align-right)`

- Rich content button group

  `vaadin-rich-text-editor::part(toolbar-group-rich-text)`

- Image button

  `vaadin-rich-text-editor::part(toolbar-button-image)`

- Link button

  `vaadin-rich-text-editor::part(toolbar-button-link)`

- Text block button group

  `vaadin-rich-text-editor::part(toolbar-group-block)`

- Block quote button

  `vaadin-rich-text-editor::part(toolbar-button-blockquote)`

- Code block button

  `vaadin-rich-text-editor::part(toolbar-button-code-block)`

- Format button group

  `vaadin-rich-text-editor::part(toolbar-group-format)`

- Clean formatting button

  `vaadin-rich-text-editor::part(toolbar-button-clean)`

### <a id="content"></a>Content

- Content area

  `vaadin-rich-text-editor::part(content)`
