Fully customize your docs
This page covers CSS and JavaScript customization:
- CSS for styling, visual changes, and hiding elements
- JavaScript for client-side behavior, third-party integrations, and widgets
For server-rendered reusable elements in your MDX content, see Custom React components. To replace Fern’s default header or footer, see Custom header and footer.
You can also customize many things directly in your docs.yml file, including colors, typography, navbar links, layout, analytics, and metadata. Try these built-in options first before adding custom code.
Custom CSS
You can add custom CSS to your docs to further customize the look and feel. The defined class names are applied across all MDX files. See the CSS selectors reference for a complete list of available .fern-* selectors.
For customizing the background, logo, font, and layout of your Docs via Fern’s built-in styling, check out the Global Configuration.
Common use cases
Hiding page elements
You can use custom CSS to hide specific Fern docs components that you don’t want to display.
You can target other Fern UI components using their CSS class names. See the CSS selectors reference for all available selectors, or use your browser’s developer tools to inspect elements.
Adding custom styling
You can use custom CSS to create brand-specific styling for tables, components, and other elements in your documentation.
Inline CSS on MDX pages
You can add CSS directly within an MDX page using a <style> tag. This is useful for page-specific styles that don’t need to be applied globally.
The CSS must be wrapped in curly braces and backticks ({``}) to be valid JSX. Use the .dark selector prefix to define styles for dark mode.
Custom JavaScript
Customize the behavior of your Docs site by injecting custom JavaScript globally.Add a custom.js file and include it in your fern/ project:
In docs.yml, specify the path to the custom.js file:
You can also specify multiple custom JS files stored locally and remote:
We use path for local sources and url for remote sources.
Strategy
Optionally, specify the strategy for each custom JavaScript file. Choose from beforeInteractive, afterInteractive (default), and lazyOnload.
Common use cases
-
Integrate with third-party platforms that Fern doesn’t natively support
-
Implement custom search (also requires your Algolia credentials)
-
Insert scripts and widgets