diff --git a/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts b/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts index 35d645322355..12cf2eff4c8d 100644 --- a/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts +++ b/packages/docusaurus-theme-common/src/hooks/useCodeWordWrap.ts @@ -69,6 +69,9 @@ export function useCodeWordWrap(): { codeElement.removeAttribute('style'); } else { codeElement.style.whiteSpace = 'pre-wrap'; + // When code wrap is enabled, we want to avoid a scrollbar in any case + // Ensure that very very long words/strings/tokens still wrap + codeElement.style.overflowWrap = 'anywhere'; } setIsEnabled((value) => !value);