Custom CSS, HTML, and JavaScript

StarterProEnterprise
Custom CSS
Custom JavaScript

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 {
  --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).

📘

:root vs body

Our CSS vars are targeted on the :root selector and load in after yours, so use the body selector to ensure your variables take priority!

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 {
  --font-family: 'Your Typeface';
}

Additional font family variables are available for more granular control:

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-indent15pxThe indentation space of for subpages.
--Sidebar-link-padding-y5pxVertical 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-HeaderHeader element.
.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.

Global Variables

ReadMe exposes certain global variables to help you customize the user experience of your hub:

  • RM_ReferenceSidebarScrollTopOffset
    Pixel offset for the scroll-to-active-item sidebar logic in continuous Reference sections.

Custom Include Tags

Header HTML

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

Footer HTML

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.


Did this page help you?