Customising topic controls
Topic pages in this template use a swizzled layout (src/theme/DocItem/Layout/) and small React components for the right-hand TOC. Swizzling is a Docusaurus term for customising.
This topic covers the controls you are most likely to change for a customer portal.
| Control | Where it lives |
|---|---|
| On this page: label | src/theme/DocItem/Layout/index.js (+ styles.module.css) |
| Feedback and print buttons | src/components/DocActions/, FeedbackButton/, PrintButton/ |
| Previous / next pagination | Disabled. To get them back, restore DocItemPaginator in the layout |
Edit these files only when you are adapting the portal layout. Day-to-day topic authors usually only need front matter such as hide_table_of_contents.
On this page label
Above the desktop TOC, the layout renders a fixed label:
<p className={clsx(styles.onThisPage, 'no-print')}>On this page:</p>
Change the text
Edit the string in that <p> (for example On this page without the colon, or a translated label).
Change the look
Update .onThisPage in src/theme/DocItem/Layout/styles.module.css (size, weight, colour). The colour currently follows --ifm-toc-link-color so it matches TOC links.
Remove the label only
Delete the <p …>On this page:</p> line (keep {docTOC.desktop} so the TOC list still shows).
Hide the whole TOC (label and list)
On one topic, use front matter:
---
title: Example
hide_table_of_contents: true
---
To change which heading levels appear in the TOC, see Editing sidebar and TOC (tableOfContents in docusaurus.config.js).
Feedback and print buttons
Both buttons are rendered by DocActions, which appears in the right column on desktop and above the content on smaller screens:
export default function DocActions() {
return (
<div className={`no-print ${styles.docActions}`}>
<FeedbackButton />
<PrintButton />
</div>
);
}
Shared button chrome (size, border, hover) lives in src/components/PrintButton/styles.module.css. Feedback reuses those styles.
Change the feedback action
Open src/components/FeedbackButton/index.js.
Example: open a mailto link instead of Jira
Use the sample below to get the following result:
- Replace the Jira URL with a
mailto:link. - Use
encodeURIComponentfor the subject (and optional body) so spaces and special characters are safe. - Include the current page title from
metadata.title.
The minimum required change is to replace the example email address with an existing one.
export default function FeedbackButton() {
const {metadata} = useDoc();
const subject = encodeURIComponent(
`Docs feedback: ${metadata.title}`,
);
const href = `mailto:docs-feedback@example.com?subject=${subject}`;
return (
<a
className={styles.actionButton}
href={href}
aria-label="Send feedback by email"
title="Send feedback by email">
<FeedbackIcon />
</a>
);
}
Optional: add a short body that also names the page (and, if useful, its URL):
const body = encodeURIComponent(
`Feedback on “${metadata.title}”\n\nPage: ${typeof window !== 'undefined' ? window.location.href : metadata.permalink}\n\n`,
);
const href = `mailto:docs-feedback@example.com?subject=${subject}&body=${body}`;
Change the print action
Open src/components/PrintButton/index.js.
- Default behaviour is
onClick={() => window.print()}. - Point elsewhere by changing the handler (or replace the
<button>with a link) if print should open a custom URL or tool. - Update
aria-labelandtitleto match.
Change an icon
Each file defines a small SVG component (FeedbackIcon / PrinterIcon). Replace the <path> (or the whole SVG) with your icon. Keep aria-hidden="true" on decorative icons; the accessible name stays on the button/link.
Hide one or both buttons
- Hide both: remove
<DocActions />fromsrc/theme/DocItem/Layout/index.js(desktop column and the mobile block). - Hide one: remove
<FeedbackButton />or<PrintButton />fromDocActions. - CSS-only (quick): target
.docActionsor a single button insrc/css/custom.csswithdisplay: noneif you need a temporary hide without touching JSX.
Previous and next buttons
Classic Docusaurus shows Previous / Next under the article via <DocItemPaginator />. This template’s swizzled layout doesn't render that component, so those links are off by default.
Re-enable pagination
- In
src/theme/DocItem/Layout/index.js, import the paginator:
import DocItemPaginator from '@theme/DocItem/Paginator';
- Place the paginator tag after
</article>, insidedocItemContainer(same position as in the classic theme):
<div className={styles.docItemContainer}>
<article>
{/* breadcrumbs, content, footer… */}
</article>
<DocItemPaginator />
</div>
- Save and refresh.
The navigation order follows the main sidebar.
Pagination respects sidebar order. If previous/next look wrong, check the doc’s place in sidebars.js.