You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/docs/pages/component-library/custom-components/custom-css-js.mdx
+9-77Lines changed: 9 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,14 @@ subtitle: Add custom CSS, global JavaScript, and UI components.
4
4
description: Learn how to add custom CSS, JavaScript, and UI components to your Fern documentation. Style your docs with custom classes and scripts.
5
5
---
6
6
7
-
This page covers how to customize your docs with CSS, JavaScript, and custom components. However, you can [customize many things directly in your `docs.yml` file](/docs/configuration/site-level-settings), including colors, typography, navbar links, layout, analytics, and metadata. Try these built-in options first before adding custom code.
7
+
This page covers CSS and JavaScript customization:
8
+
9
+
-**CSS** for styling, visual changes, and hiding elements
10
+
-**JavaScript** for client-side behavior, third-party integrations, and widgets
11
+
12
+
For server-rendered components like custom headers, footers, or reusable elements in your MDX content, see [Custom React components](/learn/docs/writing-content/custom-react-components).
13
+
14
+
You can also [customize many things directly in your `docs.yml` file](/docs/configuration/site-level-settings), including colors, typography, navbar links, layout, analytics, and metadata. Try these built-in options first before adding custom code.
- `ReactDOM.render()`may need to be called multiple times to prevent it from unmounting (this side-effect will be removed in the future).
302
-
- `yarn build`or `npm build` must generate files with deterministic names to be referenced in `docs.yml`. The above example uses a [`vite` config](https://github.com/fern-api/docs-custom-js-example/blob/main/custom-app/vite.config.ts) to accomplish this.
303
-
- For your hosted Docs site, you may need to update your CD steps to include building the react-app.
304
-
- Custom components aren't supported in local development, but are supported in preview links.
305
-
306
-
<Info>
307
-
This approach is subject to change, with notice, as we make improvements to the plugin architecture.
Copy file name to clipboardExpand all lines: fern/products/docs/pages/component-library/custom-components/custom-react-components.mdx
+33-5Lines changed: 33 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,20 +5,19 @@ description: Add custom React components to your Fern docs for interactive, serv
5
5
6
6
<Markdownsrc="/snippets/pro-plan.mdx"/>
7
7
8
-
You can extend Fern's built-in component library by adding your own custom React components.
9
-
This allows you to create unique, interactive elements that match your documentation needs.
8
+
You can extend Fern's built-in component library by adding your own custom React components. This allows you to create unique, interactive elements that match your documentation needs. Components are server-side rendered for better SEO and performance, with no layout shifts.
10
9
11
10
<Notetitle="Defining a constant">
12
11
Don't use a React component to define a constant. Instead, consider using [reusable snippets](/docs/writing-content/reusable-snippets).
13
12
</Note>
14
13
15
-
## How it works
14
+
## Custom components in MDX
16
15
17
16
<Steps>
18
17
### Create a React component
19
18
20
-
Let's start by creating a `components` folder where you can define your react components. Note
21
-
that the react components can be defined in `.ts`, `.tsx`, `.js` or `.mdx` files.
19
+
Let's start by creating a `components` folder where you can define your React components. Note
20
+
that the React components can be defined in `.ts`, `.tsx`, `.js` or `.mdx` files.
@@ -65,6 +64,35 @@ import { CustomCard } from "../components/CustomCard"
65
64
```
66
65
</Steps>
67
66
67
+
## Custom header and footer
68
+
69
+
Replace Fern's default header or footer with your own React components.
70
+
71
+
<Steps>
72
+
### Create your component
73
+
74
+
Your component file must have a default export returning a React component. Tailwind CSS classes are available, including the `dark:` prefix for dark mode styles (e.g., `dark:bg-gray-900`, `dark:text-gray-400`):
Path to a custom React component file (TSX or JSX) to replace Fern's default header. The component must have a default export. Learn more about [custom header and footer components](/learn/docs/writing-content/custom-react-components#custom-header-and-footer).
Path to a custom React component file (TSX or JSX) to replace Fern's default footer. The component must have a default export. Learn more about [custom header and footer components](/learn/docs/writing-content/custom-react-components#custom-header-and-footer).
120
+
</ParamField>
121
+
114
122
## Instances configuration
115
123
116
124
An `instance` is the backend of a distinct docs website. Each instance is published to a unique domain using the `--instance` flag. It is most common to use instances to configure staging and production docs which publish to separate URLs.
0 commit comments