Custom CSS, HTML, and JavaScript

Apply your own CSS, JavaScript, and include tags to your hub, with the plan requirements and toggles for each.

StarterProEnterprise
Custom CSS
Custom JavaScript
Custom HTML

Set these in your project under Appearance → CSS, JS, HTML.


Custom CSS

Customize your docs with CSS using either CSS variables or custom CSS rules. The most flexible is to use CSS variables.

For example: if you want to change your header background, you can set the CSS variable like so:

.App .rm-Header {
  --Header-background: #fff;
}

The other option is to write custom CSS. We expose global class names for you to use as selectors (prefixed with rm):

.rm-Header {
  background: #fff;
}

Global Selectors

Use .rm- prefixed selectors. Hashed selectors change constantly and should not be relied on as selectors (ie. Header-bottom2eLKOFXMEmh5).

📘

Scope variables to the element that uses them

ReadMe sets many variables on the element that uses them, such as --Header-* on .rm-Header and --TryIt-* on .rm-TryIt. An override on :root, body, or .App alone can be ignored, so target the element itself, as in the examples above.

Typography

The recommended way to customize fonts is through the Typography section in your Theme settings. There you can choose from Google Fonts or upload custom font files for headings, body text, and code.

If you need further control, you can override the typeface throughout your docs through CSS variables:

.App .rm-ReadMe {
  --font-family: 'Your Typeface';
}

Additional font family variables are available for more granular control. Set them on the same .App .rm-ReadMe selector:

VariableDescription
--font-familyBase font family for the project. Defaults to system typefaces.
--font-family-headingFont family for headings (h1–h6).
--font-family-monoFont family for code and monospace.
--font-base15px (Condensed) / 16px (Comfortable).
Base font size used to calculate the type scale.
--font-scale1.2 (Condensed) / 1.25 (Comfortable).
Scale ratio for the modular type scale.
--font-reading-width80ch (Condensed) / 75ch (Comfortable).
Maximum width for readable content.
--font-weight500
--font-weight-bold600

Header

Some variables vary depending on the primary color of your header background (set in the Appearance page, if it's dark or light). You can base your CSS variable overrides on light or dark by doing:

.ThemeContext_dark {
  --Header-button-color: #fff;
}

CSS Variables

This is not a comprehensive list of variables.

NameDefault ValueDescription
--Header-backgroundvar(--color-primary)--color-primary is your header background from the Appearance page of the dash.
--Header-border-colorrgba(0, 0, 0, 0.1)
--Header-border-width1px
--Header-button-colorColor of button text in the header.
--Header-button-hoverColor of the button text when it's hovered over.
--Header-button-activeColor of of the button text when it is selected.
--Header-button-focus
--Header-jumpTo-backgroundvar(--color-primary-inverse)
--Header-jumpTo-colorvar(--color-primary)
--Header-tab-padding5px 2pxAmount of padding within each navigation tab (available with the Line header option).
--Header-tab-underlinevar(--color-primary)Color of the tab underline when using tabbed navigation (available with the Line header option).
--Sidebar-border-colorrgba(0, 0, 0, 0.1)The border color of your sidebar.
--Sidebar-indent10pxThe indentation space of for subpages.
--Sidebar-link-padding-y0.429emVertical padding of each item in the sidebar
--TryIt-backgroundYour brand color.Background color of the Try It button. --color-primary is your header background from the Appearance page of the dash.
--TryIt-background-hoverThe hover background color of your brand (darkened).
--TryIt-background-activeSame as hover, but even darker.
--TryIt-background-focusThe focus ring color; also based on your brand color.
--TryIt-background-disabled
--TryIt-border-radiusvar(--border-radius-lg)
--TryIt-colorCalculated text legible color; based on your brand color.
--TryIt-spinner-color
--transition-fast.15s
--transition-slow.3s
--transition-timingcubic-bezier(.16,1,.3,1)

Global Classes

This is not a comprehensive list of classes.

NameDescription
.rm-ReadMeRoot element that wraps your hub.
.rm-HeaderHeader element.
.rm-Header_landingApplied to the header on the landing page. Sticky header CSS does not apply when this class is present.
.rm-LogoLogo element.
.rm-Logo-imgImage element within the logo container.
.rm-Header-top-linkLinks in the top section of your header.
.rm-Header-bottom-linkLinks in the bottom section of your header.
.rm-SearchToggleThe search input.
.rm-Header-top-link_loginLogin link in the top section of your header.
.rm-JumpToAccessible link that takes users to the main content.
.rm-SidebarLeft-hand sidebar element.
.rm-Sidebar-linkPage links within the sidebar element.
.rm-Sidebar-headingCategory elements in the sidebar.
.rm-Sidebar-listSemantic list of links within a category.
.rm-ToCTop-level nav element for the table of contents.
.rm-APISectionHeaderThe headings before each section in API Reference pages.
.rm-APILogInfo
.rm-APILogsTableRequest history table.
.rm-ParamContainerContainer that wraps parameters.
.rm-ParamInputText form inputs per parameter.
.rm-ParamSelectSelect form inputs per parameter.
.rm-APIResponseSchemaPickerResponse schema button.
.rm-PaginationWrapper for the previous / next navigation buttons at the bottom of the page.
.rm-LanguageButtonLanguage buttons.
.rm-LanguageButton-moreOverflow language button.
.rm-PlaygroundRequestRequest example for the endpoint.
.rm-TryItTry It button.
.rm-PlaygroundResponseResponse example for the endpoint.

Color Schemes

There are two selectors you should use when targeting dark mode styles. The first applies when the color scheme is set to system and a user is not toggling dark or light modes.

@media (prefers-color-scheme: dark) {
  [data-color-mode="system"] YOUR_SELECTOR {
    /* CSS goes here */
  }
}

The second selector to use is for users who want to use dark mode, even when their system is set to light:

[data-color-mode="dark"] YOUR_SELECTOR {
  /* CSS goes here */
}

That’s it! You’ll need to use both selectors for everything to work. Here’s an example with everything together, to change the background color of the “Try It” button:

.App .rm-TryIt {
  --TryIt-background: yellow;
}

@media (prefers-color-scheme: dark) {
  [data-color-mode="system"] .App .rm-TryIt {
    --TryIt-background: purple;
  }
}

[data-color-mode="dark"] .App .rm-TryIt {
  --TryIt-background: purple;
}

Custom Javascript

Your Javascript will be included at the bottom of the page.

Your hub is a single-page app, so this script runs once when the hub first loads, not each time a reader moves to another page. To run code on every page, use the pageLoad event:

$(window).on('pageLoad', () => {
  // Runs on the first page load and after each navigation
});

Custom Include Tags

Head Tag

Any html here will be included in the head tag, which is good for things like meta tags and loading external CSS or JS.

End of Body Tag
​
This will go right before the </body> tag. Good for things like analytics and tracking.

Toggling Custom Javascript and CSS

Add the ?disableCustomCss=true&disableCustomJs=true query params to the end of any URL.

This works in public view, for example in a private or incognito window. When you're logged in to ReadMe, your hub loads inside the editor's preview, which doesn't pick up these params.


Did this page help you?