Custom CSS

Available in Grow Projects

Apply project-wide CSS changes and enable complete design control using Custom CSS.

If you wish to apply (or test) on a version, then you can use the selector .customise .version-{{versionSlug}}.

Customizing CSS

To customize CSS:

  • Open Project Settings from the Sidebar.
  • Under Customize, select Edit CSS.
  • Enter the custom CSS, and click Save. This will save the CSS in draft mode, so you can test it out.
  • To publish it to readers, click Save & Publish.
  • To revert the draft changes, click Revert.

The CSS will be applied instantly, ensuring that your changes take effect without delay.

Testing CSS

To ensure your CSS modifications are functioning as intended before delivering them to your customers, it's important to test your changes thoroughly. To begin testing your CSS, simply click on the Save button located in the Custom CSS window. At this point, the updated CSS will take effect immediately within the editor, allowing you to see the results in real time. Additionally, if you utilize any of the Go To buttons available in the sidebar, you will also be able to observe your CSS changes reflected in the published documents. This enables a comprehensive review of your styles prior to final deployment.

If you want to double check what your readers see after you click the Go To button, then open the published docs in an incognito window of your browser.

You can revert the changes from the Custom CSS window.

When you revert the CSS, the draft changes are discarded and lost.

To test latest frontend application on the readers site if your frontend application is pinned, add ?deployment_id=latest to the URL. To confirm which application version is being used, check the X-DeveloperHub-Version header in the first network request.

Testing Dark Theme

To test the dark theme without enabling it for your readers, utilize the Change Theme function. This approach allows you to apply the dark theme temporarily without altering the project settings, ensuring that your audience remains unaffected during the testing process.

Disabling Styles

To determine if a style applied through Custom CSS is causing any issues, you can temporarily disable all custom styles for your browser. Simply append the query ?disableStyles=true to the URL of any published document. This allows you to see how the document renders without the influence of custom styles, helping you identify any potential problems.

If your docs are at [https://example.com/docs](https://example.com/docs), you can turn off custom styles for your session by using [https://example.com/docs?disableStyles=true](https://example.com/docs?disableStyles=true).

After refreshing the page without using disableStyles=true, your custom styles will be reactivated automatically.

Why customize CSS?

By customizing CSS, you can:

  • Apply an image to the navigation header.
  • Change the index style.
  • Add icons to categories in the index, or apply a smooth colour transform like in our docs.
  • Animate buttons.
  • Import another CSS file using @import url(...) .
  • Use your own custom (non Google Font) font.
  • Create a custom landing page, removing sidebars and titles.
  • Change the code theme.
  • Or anything you can think of, really...

The CSS is not encapsulated, meaning it applies globally across the application. Since the DeveloperHub CSS changes frequently, we cannot guarantee a consistent design; for more details, please refer to our guide on Pinning Frontend Application Version. To ensure your styles are applied as intended, you may want to consider adding !important to your CSS declarations.

CSS Best Practices

DeveloperHub CSS is not encapsulated and applies globally. This means that you can change everything - including what you see in the editor, including the editor itself! With this amount of great power, comes great responsibility, so make sure you follow these best practices. The examples will work through one case: "How to change the colour of the page title".

Make certain that any Custom CSS modifications are compatible with all display sizes and input devices. The default CSS is crafted to function seamlessly across phones, tablets, laptop screens, and larger displays. It is essential to rigorously test the CSS changes you implement on all screen sizes to guarantee a satisfactory experience for readers.

1 Use .customise

.customise is a CSS selector that you should use for all your CSS rules. It includes everything that the editor does not, which is what you may want to customize. For example:

CSS
Copy

2 Use .live

.live is a CSS selector that you should use in your CSS rules. It ensures that the CSS only loads on your live docs site and not in the editor. If you change the page styles in the editor, it may cause inconsistencies and break features if the CSS isn't written carefully. Therefore, it's best to have these styles apply only on the live docs site. For example:

CSS
Copy

3 Use specific selectors

In our previous examples, h1 serves as a rather broad selector. To effectively modify the page title color, it is advisable to use a more specific selector, particularly within the context of Documentation. This approach ensures precise targeting and avoids unintended style changes to other elements.

CSS
Copy

Changing the CSS of generic selectors like table, p, .container, .row, img, etc. will alter the overall appearance and may disrupt the editor and live view functionality. We use Bootstrap extensively, so altering its default styles is not advised. Instead, choose a specific selector to apply your styles.

If you're making a landing page, create specific selectors. For instance, if you want to use a .container, also add a .x-container selector to it and apply styles to .x-container instead of the general .container.

CSS Customization Examples

See Popular Customisations.

Examples on Page

As we are committed to preserving the style of our documentation, which we deeply appreciate, we will present some styled items in this section.

  • Sign up now button with hover effect.
  • Links to other documentations.
  • Sign up forms.
Sign up for our updates

We'll send you updates every week

CSS Variables

We have created configurable variables that allow you to easily adjust the look and feel of your interface. When you set theme, these variables will be automatically updated to reflect your changes.

CSS
Copy

To modify the variables used when dark theme is enabled, use the selector .dark-mode, for example:

CSS
Copy

Font Weights

If your assigned font does not have all the weights we use on DeveloperHub then you can reassign some weights to another:

CSS
Copy

For example, if weight 500 does not exist, then you may set --fw-500: 600, so font weight 600 is used whenever 500 is expected.

We have more variables which are not mentioned here, such as --shadeX and --helperX which are not built to be modified by the user. Changing them will definitely lead to unexpected results.

Pinning Frontend Application Version

As we continue to enhance the features of DeveloperHub, we may update the DOM, CSS, and JavaScript components that contribute to your documentation site. It's important to note that these updates could potentially impact your custom CSS modifications, especially if you have implemented significant changes. Consequently, this may result in unexpected alterations to the site's appearance.

To prevent unexpected changes from impacting your users, you have the option to pin the frontend application version to a specific deployment. This ensures that any modifications made to the single-page application will not be visible to your readers until you decide to update it. Additionally, we may automatically pin your frontend application version during significant updates that could potentially affect any custom CSS modifications you have implemented.

To pin your frontend application version:

  • From the left sidebar, click on Project Settings .
  • Under Advanced Settings, click the button next to Pin frontend application version.
  • Choose a version according to its date and description.

To unpin the frontend application version, choose Latest version.

Change might take up to 5 minutes to reflect on the docs site. The change only reflects on the readers site, not in the editor.

This stops all updates to your docs site and ensures your reader doesn't see unexpected styles. You should change the custom CSS as soon as you can and switch back to the Latest version. We can't promise that older versions will keep working.

Migrating to Latest Frontend Application Version

If you are using an older version of the application and want to update to the latest version for new features, follow these steps:

  1. Test how the docs would look with latest frontend application version

To test the latest frontend application on the readers site, if your application is pinned, add ?deployment_id=latest to the URL. To check which version is being used, look at the X-DeveloperHub-Version header in the first network request.

Load at least the landing page, documentation page, and API reference with ?deployment_id=latest appended to the end of the URLs. Assess whether the pages appear as intended. If any discrepancies are found, adjust the CSS/JS in draft mode and continue refining until the pages look flawless.

Make sure that everytime you reload the page and wish to see it in latest application version, you add ?deployment_id=latest.

  1. Publish CSS/JS changes

Now that your CSS and JavaScript changes are finalized and flawless, it is time to share them with your audience. Publish these updates for your readers to enjoy!

  1. Unpin frontend application version

To unpin your frontend application version:

  • From the left sidebar, click on Project Settings .
  • Under Advanced Settings, click the button next to Pin frontend application version.
  • Choose "Latest".
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
  Last updated