Skip to content

Commit 7edce29

Browse files
committed
docs: update for v4 release + add migration guide
1 parent 9318b8f commit 7edce29

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
## Features
2424

25-
- Add `.${color}-mode` class to `<html>` for easy CSS theming
25+
- Add `.${color}` class to `<html>` for easy CSS theming
2626
- Force a page to a specific color mode (perfect for incremental development)
2727
- Works with client-side and universal rendering
2828
- Auto detect system [color-mode](https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-mode)
2929

3030
[📖 &nbsp;Read more](https://color-mode.nuxtjs.org)
3131

32-
**Note**: v3 of `@nuxtjs/color-mode` is compatible with [Nuxt 3+ and Nuxt Bridge](https://nuxt.com). If you're looking for the previous version of this module, check out [the previous docs](https://v2.color-mode.nuxtjs.org/), or [read more about the differences](https://color-mode.nuxtjs.org/#migrating-to-v3).
32+
**Note**: v4 of `@nuxtjs/color-mode` is compatible with [Nuxt 3+](https://nuxt.com). If you're looking for the previous version of this module, check out [the previous docs](https://v2.color-mode.nuxtjs.org/), or [read more about the differences](https://color-mode.nuxtjs.org/#migrating-to-v3).
3333

3434
## Contributing
3535

docs/content/3.advanced/2.migration.md

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,75 @@
11
---
2-
title: Migrating to v3
3-
description: Guide for migrating from v2 to v3
2+
title: Migration Guide
3+
description: Guide for migrating between major versions
44
---
55

6+
## Migrating to v4
7+
8+
v4 of `@nuxtjs/color-mode` requires Nuxt 3+ and drops support for Nuxt Bridge. It also introduces several breaking changes to improve the module.
9+
10+
### Main Changes
11+
12+
#### 1. No Default Class Suffix
13+
14+
The default `classSuffix` has been removed. If you were relying on the default `-mode` suffix, you'll need to explicitly set it in your configuration:
15+
16+
```ts
17+
export default defineNuxtConfig({
18+
colorMode: {
19+
classSuffix: '-mode'
20+
}
21+
})
22+
```
23+
24+
Or update your CSS classes to remove the suffix:
25+
26+
```diff
27+
- .dark-mode { }
28+
- .light-mode { }
29+
+ .dark { }
30+
+ .light { }
31+
```
32+
33+
#### 2. CommonJS Support Dropped
34+
35+
The module no longer provides CommonJS builds. Ensure your project is using ESM (which is the default for Nuxt 3).
36+
37+
#### 3. Read-Only Color Mode Value
38+
39+
You can no longer directly set `colorMode.value`. Use `colorMode.preference` instead:
40+
41+
```diff
42+
<script setup>
43+
const colorMode = useColorMode()
44+
45+
- colorMode.value = 'dark'
46+
+ colorMode.preference = 'dark'
47+
</script>
48+
```
49+
50+
The `value` property is now read-only and reflects the actual color mode being used (which may differ from `preference` when using system preference detection).
51+
52+
#### 4. Removed `hid` Option
53+
54+
The defunct `hid` configuration option has been removed. If you were using it in your config, simply remove it:
55+
56+
```diff
57+
export default defineNuxtConfig({
58+
colorMode: {
59+
- hid: 'nuxt-color-mode-script',
60+
preference: 'system',
61+
}
62+
})
63+
```
64+
65+
#### 5. Nuxt Bridge Support Dropped
66+
67+
Support for Nuxt Bridge has been removed. If you're still using Nuxt Bridge, you should continue using v3. Otherwise, upgrade to Nuxt 3+.
68+
69+
---
70+
71+
## Migrating to v3
72+
673
v3 of `@nuxtjs/color-mode` requires either Nuxt Bridge or Nuxt 3+. If you are using Nuxt 2 without Bridge, you should continue to use v2.
774

875
## Main Changes

0 commit comments

Comments
 (0)