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}}.

Customising CSS

To customise CSS:

  • Open Project Settings from the Sidebar.
  • Under Customise, 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 immediately.

Testing CSS

You probably want to test your CSS changes before shipping them to your customers. To test CSS, click on Save in the Custom CSS window. At this stage, the CSS will be applied immediately inside the editor. Also, if you use any of the Go To buttons from the sidebar, then you will also see the CSS changes on the published docs.

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 dark theme without enabling it for your readers, use Change Theme function to apply the theme without modifying the project settings.

Disabling Styles

For testing if a style applied using Custom CSS is causing issues, you might want to disable all custom styles momentarily only for your browser. To do this, append a query ?disableStyles=true to any published docs URL.

For example, if your docs are available on https://example.com/docs then you can disable customs styles for your session using https://example.com/docs?disableStyles=true.

Once you refresh the page without disableStyles=true, custom styles will be enabled again.

Why customise CSS?

By customising 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 and applies globally. DeveloperHub CSS does change frequently, and we cannot guarantee consistent design (check Pinning Frontend Application Version). You might want to add !important to your styles.

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".

Ensure that any Custom CSS changes adhere to all display sizes and input devices. The default CSS is designed to work for phones, tablets, laptop screens and large screens. Always test the CSS changes you make on all sizes to ensure reader satisfaction.

1 Use .customise

.customise is a CSS selector which you should probably use on all your CSS rules. .customise encapsulates everything that the editor is not, which is everything you might want to customise. For example:

CSS
Copy

2 Use .live

.live is a CSS selector which you should probably use on all your CSS rules. .live encapsulates CSS that only loads on your live docs site, but not when in the editor. Changing the page styles in the editor could cause inconsistencies and features to break if CSS is not very carefully written, so it is best to only have these styles apply on the live docs site. For example:

CSS
Copy

3 Use specific selectors

In our previous examples, h1 is quite a vague selector. If we want to change the page title colour, then it's best to use it's specific selector and only in Documentation.

CSS
Copy

Changing the CSS of generic selectors like table, p, .container, .row, img, etc... will modify the global look and would probably break functionality of both the editor and the live view. We use Bootstrap heavily and changing its standard styles is not recommended. Instead, find a specific selector to apply the styles on.

If you are creating a landing page, then create specific selectors. For example, if you wanted to use a .container, then also add a .x-container selector on the container, and apply the styles on .x-container instead of the generic .container.

CSS Customisation Examples

See Popular Customisations.

Examples on Page

As we do not want to change the style of our documentation (since we love it so much), we'll show some styled items here.

  • 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 set up variables for you to change, so you can change the look and feel easily. When theme is set, those variables automatically get modified.

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 build out new features for DeveloperHub, we might change the DOM, CSS and javascript we ship that makes up your docs site. These changes might interfere with your custom CSS changes (if you have heavy changes) and cause unexpected site style.

To prevent this from happening, you can pin the frontend application version to a certain deployment. That means that any change we make to the single-page application would not be reflected to your readers. We also might pin your frontend application version automatically when we do big changes that may affect any custom CSS changes.

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.

While this ensures that your reader does not see unexpected styles, this also stops all updates to your docs site. You are expected to modify the custom CSS as soon as possible and return to Latest version. We do not guarantee that older versions will remain functioning.

Migrating to Latest Frontend Application Version

If you are pinned to a different application version and wish to move to the latest frontend application version in order to get the latest features, do the following:

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

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.

Load at least the landing page, documentation page and API reference with ?deployment_id=latest at the end of the URL and check if the pages look as expected. Otherwise, modify the CSS/JS in draft mode and keep on iterating until the pages look perfect.

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

As your CSS/JS changes are now perfect, publish them to your readers.

  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 by Zaid Daba'een
customisation