Compatibility with CSS frameworks

CKEditor 5 is compatible with most of the popular CSS frameworks. However, to properly integrate with some of them, additional tweaks may be necessary. This is mostly due to the fact that:

  • CSS frameworks often use a higher CSS Specificity in their style sheets and override default editor styles, distorting the user interface.
  • Modal components of various UI frameworks use high z-index values in their styles and render over (cover) the UI of CKEditor 5.
  • Framework modals use aggressive focus management policy which breaks the input fields in the rich-text editor (e.g. the link input). In this guide, you will learn how to address these integration issues and use the CKEditor 5 WYSIWYG editor with the most popular front–end frameworks.

Compatibility with Bootstrap

Bootstrap modals

We noticed that Bootstrap modals cover the UI of the rich-text editor and break the input fields. Knowing that, you will need to take the following steps to get CKEditor 5 working in the Bootstrap environment:

  • Configure the z-index of the floating editor UI (e.g. balloons) so it is displayed over the Bootstrap overlay.
  • Configure Bootstrap so it stops “stealing” the focus from the rich-text editor input fields. To address the first issue, add the following styles to your application:
  1. /*
  2. * Configure the z-index of the editor UI, so when inside a Bootstrap
  3. * modal, it will be rendered over the modal.
  4. */
  5. :root {
  6. --ck-z-default: 100;
  7. --ck-z-modal: calc( var(--ck-z-default) + 999 );
  8. }

Pass the focus: false option to Bootstrap modal() function to fix the second issue:

  1. $( '#modal-container' ).modal( {
  2. focus: false
  3. } );

Check out the demo of CKEditor 5 rich-text editor working correctly with Bootstrap.

Bootstrap table styles

There is also a known issue concerning table styles brought by Bootstrap breaking the table (widget) layout during editing. If you do not want any additional space around edited tables when using Bootstrap, add the following styles to your application:

  1. /*
  2. * Override the width of the table set by Bootstrap content styles.
  3. * See: https://github.com/ckeditor/ckeditor5-table/issues/154.
  4. */
  5. .ck-content .table {
  6. width: auto;
  7. }

Compatibility with Foundation

CKEditor 5 requires some minor adjustments to the z-index of the UI to work properly with Foundation (and with the Reveal modal, too).

  1. /*
  2. * Configure the z-index of the editor UI, so when inside a Reveal modal,
  3. * it will be rendered over the modal.
  4. */
  5. :root {
  6. --ck-z-default: 100;
  7. --ck-z-modal: calc( var(--ck-z-default) + 999 );
  8. }

Check out the demo of CKEditor 5 rich-text editor working correctly with Foundation.

Compatibility with Materialize

If you want to use CKEditor 5 with Materialize.css you will need to take the following steps:

  • Configure the base z-index of the floating editor UI so it is displayed over the Materialize modals.
  • Bring back the default .ck-input class appearance (because Materialize overrides it with a higher specificity).
  • Bring back the default <ul> and <li> appearance (because Materialize overrides it).
  • Configure modals so they stop “stealing” the focus from the rich-text editor input fields. Use the following CSS to address the issues with the z-index and selector specificity:
  1. /*
  2. * Configure the z-index of the editor UI, so when inside a Materialize
  3. * modal, it will be rendered over the modal.
  4. */
  5. :root {
  6. --ck-z-default: 100;
  7. --ck-z-modal: calc( var(--ck-z-default) + 999 );
  8. }
  9. /*
  10. * Bring back the default CKEditor 5 input appearance by overriding
  11. * high–specificity styles brought by materialize.css.
  12. *
  13. * See: https://github.com/Dogfalo/materialize/blob/v1-dev/sass/components/forms/_input-fields.scss#L10-L40
  14. */
  15. .ck input.ck-input.ck-input-text {
  16. box-shadow: var(--ck-inner-shadow),0 0;
  17. background: var(--ck-color-input-background);
  18. border: 1px solid var(--ck-color-input-border);
  19. padding: var(--ck-spacing-extra-tiny) var(--ck-spacing-medium);
  20. transition-property: box-shadow,border;
  21. transition: .2s ease-in-out;
  22. height: inherit;
  23. width: inherit;
  24. font-size: inherit;
  25. margin: 0;
  26. box-sizing: border-box;
  27. }
  28. .ck input.ck-input.ck-input-text:focus {
  29. border: var(--ck-focus-ring);
  30. box-shadow: var(--ck-focus-outer-shadow),var(--ck-inner-shadow);
  31. }
  1. /*
  2. * Bring back the default <ul> and <li> appearance.
  3. *
  4. * See: https://github.com/Dogfalo/materialize/blob/v1-dev/sass/components/_global.scss#L28-L37
  5. */
  6. .ck.ck-content ul,
  7. .ck.ck-content ul li {
  8. list-style-type: inherit;
  9. }
  10. .ck.ck-content ul {
  11. /* Default user agent stylesheet, you can change it to your needs. */
  12. padding-left: 40px;
  13. }

To change the behavior of the modals and prevent them from “stealing” the focus, use the dismissible: false option.

  1. M.Modal.init( modal, { dismissible: false } );
  2. // Or "jQuery way":
  3. $( '#modal-container' ).modal( {
  4. dismissible: false
  5. } );

Check out the demo of CKEditor 5 rich-text editor working correctly with Materialize.css.

Compatibility with Semantic-UI

CKEditor 5 works properly with Semantic-UI after a small CSS tweak. To use the balloon editor inside a modal, it is necessary to configure the z-index property of the floating editor UI to make it render over the modal:

  1. /*
  2. * Configure the z-index of the editor UI, so when inside a Semantic-UI modal,
  3. * it will be rendered over the modal.
  4. */
  5. :root {
  6. --ck-z-default: 100;
  7. --ck-z-modal: calc( var(--ck-z-default) + 999 );
  8. }

Check out the demo of CKEditor 5 rich-text editor working correctly with Semantic-UI.