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
Makes use of the user's prefers-color-scheme value. A nice side effect
is that by using CSS vars, it's possible to customize the themes of the
gem as well.
Fixes#104
Copy file name to clipboardExpand all lines: README.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,81 @@ In your ERB layouts, there are several helper methods you can use. The helper me
127
127
128
128
To call these methods within templates, you must use the dot notation, such as `<%= slugify.(text) %>`.
129
129
130
+
## Dark Mode Support
131
+
132
+
GraphQLDocs includes built-in dark mode support that automatically adapts to the user's system preferences using the `prefers-color-scheme` media query. When a user has dark mode enabled on their operating system, the documentation will automatically display with a dark theme.
133
+
134
+
### Customizing Colors
135
+
136
+
The default styles use CSS custom properties (variables) for all colors, making it easy to customize the color scheme to match your brand. You can override these variables by providing a custom stylesheet.
To customize the colors, create a custom CSS file and load it after the default styles. You can override specific variables while keeping the rest of the defaults:
181
+
182
+
```css
183
+
/* custom-theme.css */
184
+
:root {
185
+
--text-link: #0066cc; /* Change link color to blue */
186
+
--bg-tertiary: #f0f0f0; /* Lighter API boxes */
187
+
}
188
+
189
+
@media (prefers-color-scheme: dark) {
190
+
:root {
191
+
--text-link: #66b3ff; /* Lighter blue for dark mode */
192
+
--bg-primary: #0d1117; /* GitHub-like dark background */
193
+
--bg-secondary: #161b22;
194
+
}
195
+
}
196
+
```
197
+
198
+
Then reference it in your custom template by overriding the `default` template and adding a link to your stylesheet:
0 commit comments