Skip to content

Commit 452a87d

Browse files
committed
Apply changesets and update CHANGELOG
1 parent 1c426fa commit 452a87d

File tree

1 file changed

+6
-41
lines changed

1 file changed

+6
-41
lines changed

lib/README.md

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ The `nextjs-themes` library was initially created to achieve a similar functiona
3838

3939
- ✅ Manipulate theme via the `useMode` hook
4040

41-
- ✅ No cookies when not using the corresponding `ServerTarget`
42-
4341
- ✅ Comprehensive documentation with [Typedoc](https://react18-tools.github.io/nextjs-darkmode)
4442

4543
Feel free to [request new features](https://github.com/react18-tools/nextjs-darkmode/issues/new?assignees=&labels=&projects=&template=feature_request.md&title=), [discuss](https://github.com/react18-tools/nextjs-darkmode/discussions), or [report bugs](https://github.com/react18-tools/nextjs-darkmode/issues/new?assignees=&labels=&projects=&template=bug_report.md&title=).
@@ -108,7 +106,7 @@ $ yarn add nextjs-darkmode-lite
108106

109107
> Please explore `examples` and `packages/shared-ui` for more working examples. (updates coming soon...)
110108
111-
### SPA (e.g., Vite, CRA) and Next.js pages directory (No server components)
109+
### SPA (e.g., Vite, CRA) and Next.js pages directory
112110

113111
Modify `_app` to add dark mode support:
114112

@@ -135,21 +133,19 @@ export default MyApp;
135133

136134
> For `vite` or any other build tool, find a similar root component, e.g., `<App />` in `CRA` and `vite`.
137135
138-
### With Next.js `app` router (Server Components)
136+
### With Next.js `app` router
139137

140-
Update `app/layout.jsx` to add `Core` and `ServerTarget` to avoid flash of un-themed content:
138+
Update `app/layout.jsx` to add `Core` component.
141139

142140
```tsx
143141
// app/layout.jsx
144142
import { Core } from "nextjs-darkmode"; // for better tree-shaking
145-
import { ServerTarget } from "nextjs-darkmode/server";
146143

147144
export default function Layout({ children }) {
148145
return (
149146
<html lang="en">
150147
<head />
151148
<body>
152-
<ServerTarget />
153149
<Core />
154150
{children}
155151
</body>
@@ -158,26 +154,6 @@ export default function Layout({ children }) {
158154
}
159155
```
160156

161-
If you prefer SSR over SSG for your entire app, you can wrap entire app with `ServerTarget` as follows:
162-
163-
```tsx
164-
// app/layout.jsx
165-
import { Core } from "nextjs-darkmode"; // for better tree-shaking
166-
import { ServerTarget } from "nextjs-darkmode/server";
167-
168-
export default function Layout({ children }) {
169-
return (
170-
<ServerTarget tag="html" lang="en">
171-
<head />
172-
<body>
173-
<Core />
174-
{children}
175-
</body>
176-
</ServerTarget>
177-
);
178-
}
179-
```
180-
181157
### Switch
182158

183159
An elegant color switch to toggle color schemes:
@@ -188,7 +164,7 @@ An elegant color switch to toggle color schemes:
188164

189165
### HTML & CSS
190166

191-
Fully support dark mode, including system preference with `prefers-color-scheme`. The dark/light mode is synced between tabs and modifies the `className` and data-attributes on the `html` or ServerTarget element:
167+
Fully support dark mode, including system preference with `prefers-color-scheme`. The dark/light mode is synced between tabs and modifies the `className` and data-attributes on the `html` elemnt.
192168

193169
```css
194170
:root {
@@ -206,19 +182,10 @@ Fully support dark mode, including system preference with `prefers-color-scheme`
206182
[data-rm="dark"] {...}
207183
```
208184

209-
When using `ServerTarget`, use the CSS general sibling combinator (~):
210-
211-
```css
212-
.selector,
213-
.selector *,
214-
.selector ~ *,
215-
.selector ~ * * {
216-
--th-variable: value;
217-
}
218-
```
219-
220185
#### Using the data-attributes
221186

187+
data-attributes are very helpful when you want to customize styles in a CSS module file (`styles.module.css`)
188+
222189
`data-rm` -> Resolved Mode
223190

224191
`data-m` -> User's preference
@@ -352,8 +319,6 @@ Now you can use dark-mode specific classes:
352319
<h1 className="text-black dark:text-white">
353320
```
354321

355-
> When you use Tailwind, make sure you replace `html` in `app/layout` to `<ServerTarget tag="html"...` to avoid FOUC.
356-
357322
## Performance
358323

359324
`nextjs-darkmode` is designed to be fully tree-shakable, including only the code you use. For instance, if you only use the `useMode` hook, the rest of the library's code will be removed during the build process.

0 commit comments

Comments
 (0)