-
Notifications
You must be signed in to change notification settings - Fork 151
/
styling.mdx
331 lines (262 loc) · 8.79 KB
/
styling.mdx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
---
title: Style your docs to match your brand
description: Configure your site's primary accent color, background image, logo, favicon, light and dark mode, and fonts.
---
Every Fern Docs website has a configuration file called `docs.yml`. Use this file to set the theme for your docs, including the primary accent color, background image, logo, favicon, light & dark mode, and fonts.
## Colors
### Primary accent
You can specify a primary accent color using the [hexadecimal color](https://www.w3schools.com/colors/colors_hexadecimal.asp). The primary accent color is used for several purposes, including:
- to indicate the page a user is on within the navigation
- as the background of a primary link button
- to underline hyperlinks
- the next and previous page navigation buttons
In `docs.yml`, you can set a single primary accent color or specify different colors for light and dark modes:
<CodeBlocks>
<CodeBlock title="single color">
```yaml
colors:
accentPrimary: "#ADFF8C"
```
</CodeBlock>
<CodeBlock title="light and dark mode colors">
```yaml
colors:
accentPrimary:
light: "#418326"
dark: "#ADFF8C"
```
</CodeBlock>
</CodeBlocks>
### Background color
Just like `accentPrimary`, you can specify the background color in `docs.yml` using the [hexadecimal color](https://www.w3schools.com/colors/colors_hexadecimal.asp).
<CodeBlocks>
<CodeBlock title="single color">
```yaml
colors:
accentPrimary: "#a6d388"
background: "#0d0e11"
```
</CodeBlock>
<CodeBlock title="light and dark mode">
```yaml
colors:
accentPrimary:
light: "#418326"
dark: "#ADFF8C"
background:
light: "#ffffff"
dark: "#0d0e11"
```
</CodeBlock>
</CodeBlocks>
## Images
### Background image
Customize the background image by including the image(s) in your `fern/` project and specifying the path in `docs.yml`. The PNG, SVG, and JPG image formats are supported.
<CodeBlock title="Add the images">
```diff
fern/
├─ openapi/
├─ pages/
+ ├─ images/
+ ├─ background-light.svg
+ └─ background-dark.svg
├─ docs.yml
└─ fern.config.json
```
</CodeBlock>
In `docs.yml`, you can set a single background image or specify different images for light and dark modes:
<CodeBlocks>
<CodeBlock title="single image">
```yaml
background-image: ./images/background.svg
```
</CodeBlock>
<CodeBlock title="light and dark mode images">
```yaml
background-image:
light: ./images/background-light.svg
dark: ./images/background-dark.svg
```
</CodeBlock>
</CodeBlocks>
### Logo
Specify a logo in `docs.yml` which gets displayed in the top left of your docs.
<CodeBlocks>
<CodeBlock title="single color">
```yaml
logo: ./images/logo.png
```
</CodeBlock>
<CodeBlock title="light and dark mode">
```yaml
logo:
light: ./images/logo-light.png
dark: ./images/logo-dark.png
```
</CodeBlock>
</CodeBlocks>
#### Logo properties
`light` or `dark` specifies the image file location. The supported file types are `.png` or `.svg`.
`height` is optional and sets the logo's height in pixels.
`href` is optional and provides a link for the logo, often used to point to the website's homepage. When the logo is clicked, the user is directed to this link.
<CodeBlock title="docs.yml">
```yaml
logo:
light: ./images/logo-light.png
dark: ./images/logo-dark.png
height: 60
href: https://example.com
```
</CodeBlock>
### Favicon image
Add a `favicon` image that displays in the browser tab. Supported file types are `.png` and `.ico`.
## Fonts
You can specify custom fonts for your documentation website. The supported file types are `.woff` and `.woff2`.
Include the custom fonts in your `fern/` project:
<CodeBlock title="Example custom fonts">
```diff
fern/
├─ fern.config.json
├─ generators.yml
├─ openapi/
├─ openapi.yml
+ ├─ fonts/
+ ├─ your-font-regular.woff2
+ ├─ your-font-bold.woff2
+ └─ another-font-regular.woff2
```
</CodeBlock>
Fern has three font types:
- `headingsFont`: affects page and section titles; if not supplied, defaults to the body font
- `bodyFont`: affects paragraph text and other body text
- `codeFont`: affects code blocks and inline code snippets
To customize the font used for each font type, add a top-level `typography` list to `docs.yml`. Then in it, specify the path of your font file for one or more of the font types.
A font has two properties:
- `name`: the name of the font; defaults to a generated name that will be used to reference your custom font in the eventually injected CSS
- `path`: the path to the font file
<CodeBlock title="Example of specifying custom fonts in docs.yml">
```yaml
typography:
bodyFont:
name: Inter-Regular
path: ./fonts/Inter-Regular.woff2
headingsFont:
name: Inter-Bold
path: ./fonts/Inter-Bold.woff2
codeFont:
name: Roboto-Mono-Regular
path: ./fonts/Roboto-Mono-Regular.woff2
```
</CodeBlock>
If the font file is not variable, you can specify font weights.
A font path has three properties:
- `path`: indicate that there are multiple font files
- `weight`: a string of weights that are supported by this font file
- `style`: the style of the font file, either `normal` or `italic`
<CodeBlock title="Example of specifying font weights in docs.yml">
```yaml
typography:
bodyFont:
name: Inter-Regular
paths:
- path: ./fonts/Inter-Regular.woff2
weight: "400"
style: normal
- path: ./fonts/Inter-Bold.woff2
weight: 500 900 # <-- indicates a range of weights
style: normal
```
</CodeBlock>
## Layout
There are several layout options you can configure in `docs.yml`. All of the layout properties are optional and give you more control over the presentation of your docs.
- `header-height`: the height of the header in pixels; the default is `4rem (64px)`
- `page-width`: the maximum width of the page content, including the sidebar and content; the default is `88rem (1408px)`
- `content-width`: the maximum width of the markdown content; the default is `44rem (704px)`
- `sidebar-width`: the width of the sidebar in desktop mode; the default is `18rem (288px)`
- `searchbar-placement`: the placement of the search bar; the options are `sidebar` (default) or `header`
- `tabs-placement`: the placement of the tabs; the options are `sidebar` (default) or `header`
- `content-alignment`: the alignment of the markdown content; the options are `center` (default) and `left`
<Tab title="Example specifying layout in docs.yml">
```yaml
layout:
header-height: 70px
page-width: 1344px
content-width: 672px
sidebar-width: 336px
searchbar-placement: header
tabs-placement: header
content-alignment: left
```
</Tab>
## Custom CSS
<Note>Custom CSS is available on the Business plan.</Note>
You can add custom CSS to your docs to further customize the look and feel. Add a `styles.css` file and include it in your `fern/` project:
<Tab title="Add the styles.css file">
```diff
fern/
├─ openapi/
├─ pages/
├─ images/
+ ├─ styles.css
├─ docs.yml
└─ fern.config.json
```
</Tab>
In `docs.yml`, specify the path to the `styles.css` file:
<Tab title="Example specifying custom CSS in docs.yml">
```yaml
css: ./docs/styles.css
```
</Tab>
Here's an example of what you can do with custom CSS:
<Tab title="Example styles.css">
```css
.petstore-table {
background-color: white;
border: 1px solid #DEDEE1;
border-radius: 4px;
}
.dark .petstore-table {
background-color: #1e1e1e;
border: 1px solid #2e2e2e;
}
.petstore-table thead {
position: sticky;
top: 0;
}
.petstore-table thead tr {
background-color: #edecee;
border: 1px solid #DEDEE1;
border-radius: 4px 4px 0px 0px;
}
.dark .petstore-table thead tr {
background-color: #2e2e2e;
border: 1px solid #2e2e2e;
}
.petstore-table th {
padding: 6px;
}
.petstore-table tbody td {
padding: 6px;
}
.petstore-table tbody tr:nth-child(odd) {
border: 1px solid #DEDEE1;
}
.petstore-table tbody tr:nth-child(even) {
border: 1px solid #DEDEE1;
background-color: #f7f6f8;
}
.dark .petstore-table tbody tr:nth-child(odd) {
border: 1px solid #2e2e2e;
}
.dark .petstore-table tbody tr:nth-child(even) {
border: 1px solid #2e2e2e;
background-color: #2e2e2e;
}
```
</Tab>
## Custom JavaScript
<Note>Custom JS is available on the Business plan.</Note>
## Header and footer
<Note>Custom Components is available on the Enterprise plan.</Note>
You can bring your own UI components and replace the default components. The `header` and `footer` are the most common components to replace. You can replace any component in the docs, including the sidebar, tabs, search bar, and more.