Custom CSS, HTML, and JavaScript
| Starter | Pro | Enterprise | |
|---|---|---|---|
| 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 SelectorsUse
.rm-prefixed selectors. Hashed selectors change constantly and should not be relied on as selectors (ie.Header-bottom2eLKOFXMEmh5).
:root vs bodyOur CSS vars are targeted on the
:rootselector and load in after yours, so use thebodyselector 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:
| Variable | Description |
|---|---|
--font-family | Base font family for the project. Defaults to system typefaces. |
--font-family-heading | Font family for headings (h1–h6). |
--font-family-mono | Font family for code and monospace. |
--font-base | 15px (Condensed) / 16px (Comfortable). Base font size used to calculate the type scale. |
--font-scale | 1.2 (Condensed) / 1.25 (Comfortable). Scale ratio for the modular type scale. |
--font-reading-width | 80ch (Condensed) / 75ch (Comfortable). Maximum width for readable content. |
--font-weight | 500 |
--font-weight-bold | 600 |
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.
| Name | Default Value | Description |
|---|---|---|
--Header-background | var(--color-primary) | --color-primary is your header background from the Appearance page of the dash. |
--Header-border-color | rgba(0, 0, 0, 0.1) | |
--Header-border-width | 1px | |
--Header-button-color | Color of button text in the header. | |
--Header-button-hover | Color of the button text when it's hovered over. | |
--Header-button-active | Color of of the button text when it is selected. | |
--Header-button-focus | ||
--Header-jumpTo-background | var(--color-primary-inverse) | |
--Header-jumpTo-color | var(--color-primary) | |
--Header-tab-padding | 5px 2px | Amount of padding within each navigation tab (available with the Line header option). |
--Header-tab-underline | var(--color-primary) | Color of the tab underline when using tabbed navigation (available with the Line header option). |
--Sidebar-border-color | rgba(0, 0, 0, 0.1) | The border color of your sidebar. |
--Sidebar-indent | 15px | The indentation space of for subpages. |
--Sidebar-link-padding-y | 5px | Vertical padding of each item in the sidebar |
--tryit-background | Your brand color. | Background color of the Try It button. --color-primary is your header background from the Appearance page of the dash. |
--tryit-background-hover | The hover background color of your brand (darkened). | |
--tryit-background-active | Same as hover, but even darker. | |
--tryit-background-focus | The focus ring color; also based on your brand color. | |
--tryit-background-disabled | ||
--tryit-border-radius | var(--border-radius-lg) | |
--tryit-color | Calculated text legible color; based on your brand color. | |
--tryit-spinner-color | ||
--transition-fast | .15s | |
--transition-slow | .3s | |
--transition-timing | cubic-bezier(.16,1,.3,1) |
Global Classes
This is not a comprehensive list of classes.
| Name | Description |
|---|---|
.rm-Header | Header element. |
.rm-Logo | Logo element. |
.rm-Logo-img | Image element within the logo container. |
.rm-Header-top-link | Links in the top section of your header. |
.rm-Header-bottom-link | Links in the bottom section of your header. |
.rm-SearchToggle | The search input. |
.rm-Header-top-link_login | Login link in the top section of your header. |
.rm-JumpTo | Accessible link that takes users to the main content. |
.rm-Sidebar | Left-hand sidebar element. |
.rm-Sidebar-link | Page links within the sidebar element. |
.rm-Sidebar-heading | Category elements in the sidebar. |
.rm-Sidebar-list | Semantic list of links within a category. |
.rm-ToC | Top-level nav element for the table of contents. |
.rm-APISectionHeader | The headings before each section in API Reference pages. |
.rm-APILogInfo | |
.rm-APILogsTable | Request history table. |
.rm-ParamContainer | Container that wraps parameters. |
.rm-ParamInput | Text form inputs per parameter. |
.rm-ParamSelect | Select form inputs per parameter. |
.rm-APIResponseSchemaPicker | Response schema button. |
.rm-Pagination | Wrapper for the previous / next navigation buttons at the bottom of the page. |
.rm-LanguageButton | Language buttons. |
.rm-LanguageButton-more | Overflow language button. |
.rm-PlaygroundRequest | Request example for the endpoint. |
.rm-TryIt | Try It button. |
.rm-PlaygroundResponse | Response 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.
Updated 14 days ago