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
@@ -74,6 +73,8 @@ export default async function RootLayout() {
74
73
75
74
With this setup, the `ThemeProvider` component will automatically inject an inline script into DOM that takes care of avoiding flicker on initial page load.
76
75
76
+
> **NOTE**: If you don't specify a `storageKey` or `defaultTheme` prop on `ThemeProvider`, default value will be used for `storageKey` while absence of `defaultTheme` would mean that the theme is automatically determined based on `prefers-color-scheme`.
77
+
77
78
2. Create a button to toggle between light and dark theme:
78
79
79
80
```jsx
@@ -90,7 +91,7 @@ export default function ToggleThemeButton() {
90
91
}
91
92
```
92
93
93
-
You can also do this manually by using `theme`, `themes`, `colors`and `setTheme()`, for example, like so:
94
+
You can also do this manually by using `theme`, `themes`, and `setTheme()`, for example, like so:
|`color`| String | The active color (`light` or `dark`). |
194
-
|`colors`| Object | Allowed colors (`{ light: 'light', dark: 'dark', auto: 'dark'|'light' }`). `colors.auto` returns `dark` or `light` based on `prefers-color-scheme`. |
195
-
|`setTheme`| Function | Setter to set new theme. |
196
-
|`toggleTheme`| Function | Toggles the theme between `light` and `dark`. When toggling from `auto`, the opposite color to active color is automatically chosen. |
|`setTheme`| Function | Setter to set new theme. |
195
+
|`toggleTheme`| Function | Toggles the theme between `light` and `dark`. When toggling from `auto`, the opposite color to active color is automatically chosen. |
|`dark`|Object|`{ type: 'dark', color: 'dark' }`| Dark theme.|
205
+
|`auto`|Object|`{ type: 'auto', color: 'dark' | 'light' }`| Auto-determine theme color based on `prefers-color-scheme`. |
207
206
208
207
> **NOTE**: The `themes` object can be used in both, client components and server components.
209
208
@@ -244,32 +243,6 @@ $ yarn test
244
243
245
244
### Troubleshooting Common Issues
246
245
247
-
#### Tailwind not updating dark mode styling
248
-
249
-
This can happen when you have your CSS or SASS file in a sub-folder that is not listed in `content` array in the `tailwind.config.js`:
250
-
251
-
```js
252
-
// ...
253
-
content: [
254
-
'./pages/**/*.{js,jsx}',
255
-
'./components/**/*.{js,jsx}',
256
-
'./app/**/*.{js,jsx}',
257
-
'./src/**/*.{js,jsx}',
258
-
],
259
-
// ...
260
-
```
261
-
262
-
To fix this, you can add the folder where your CSS or SASS file is located. For example:
263
-
264
-
```js
265
-
// ...
266
-
content: [
267
-
// ...
268
-
'./src/styles/**/*.css',
269
-
],
270
-
// ...
271
-
```
272
-
273
246
#### `Warning: Extra attributes from the server: class,style` in Console
274
247
275
248
You can safely ignore this warning as it _only_ shows on dev build and _not_ in the production build. This happens because the injected inline script adds _additional_`class` and `style` attributes to the `html` element which _do not_ originally exist on the server-side generated page, leading to a _mismatch_ in the server-side and client-side rendered page.
0 commit comments