Skip to content

Commit b06858f

Browse files
committed
chore: update Node.js engine requirement to >=20 and enhance README with new React compatibility details
1 parent 82862e2 commit b06858f

2 files changed

Lines changed: 28 additions & 13 deletions

File tree

README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a href="https://www.npmjs.com/package/react-toggle-dark-mode" target="_blank">
66
<img alt="Version" src="https://img.shields.io/npm/v/react-toggle-dark-mode.svg">
77
</a>
8-
<img src="https://img.shields.io/badge/node-%3E%3D10-blue.svg" />
8+
<img src="https://img.shields.io/badge/node-%3E%3D20-blue.svg" />
99
<a href="#" target="_blank">
1010
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
1111
</a>
@@ -17,11 +17,13 @@
1717

1818
> 🌃 Animated dark mode toggle as seen in blogs!
1919
20+
Supports React 16.14+ through 19.
21+
2022
![Interactive sun and moon transition](./docs/demo.gif)
2123

2224
## Prerequisites
2325

24-
- node >=10
26+
- node >=20
2527

2628
## Installation
2729

@@ -39,7 +41,7 @@ pnpm add react-toggle-dark-mode
3941

4042
```jsx
4143
import * as React from 'react';
42-
import * as ReactDOM from 'react-dom';
44+
import { createRoot } from 'react-dom/client';
4345
import { DarkModeSwitch } from 'react-toggle-dark-mode';
4446

4547
const App = () => {
@@ -58,6 +60,14 @@ const App = () => {
5860
/>
5961
);
6062
};
63+
64+
const rootElement = document.getElementById('root');
65+
66+
if (!rootElement) {
67+
throw new Error('Unable to find root element');
68+
}
69+
70+
createRoot(rootElement).render(<App />);
6171
```
6272

6373
## API
@@ -66,15 +76,20 @@ const App = () => {
6676

6777
#### Props
6878

69-
| Name | Type | Default Value | Description |
70-
| ------------------- | ---------------------------- | ------------------------------- | ----------------------------------------- |
71-
| onChange | \(checked: boolean\) => void | | Event that triggers when icon is clicked. |
72-
| checked | boolean | false | Current icon state. |
73-
| style | Object | | CSS properties object. |
74-
| size | number | 24 | SVG size. |
75-
| animationProperties | Object | defaultProperties \(see below\) | Override default animation properties. |
76-
| moonColor | string | white | Color of the moon. |
77-
| sunColor | string | black | Color of the sun. |
79+
| Name | Type | Default Value | Description |
80+
| ------------------- | -------------------------------------------------- | ------------------------------- | -------------------------------------------------------------------------------------------- |
81+
| onChange | \(checked: boolean\) => void | | Event that triggers when icon is clicked. |
82+
| checked | boolean | false | Current icon state. |
83+
| style | React.CSSProperties | | CSS properties object applied to the button wrapper. |
84+
| size | number \| string | 24 | SVG size. |
85+
| animationProperties | Partial animation properties object | defaultProperties \(see below\) | Override only the fields you want; missing fields are merged with defaults. |
86+
| moonColor | string | white | Color of the moon. |
87+
| sunColor | string | black | Color of the sun. |
88+
| aria-label | string | Toggle dark mode | Accessible label for the control. Ignored when `aria-labelledby` is provided. |
89+
| aria-labelledby | string | | Links the control to an external label element. |
90+
| onClick | \(event: React.MouseEvent<HTMLButtonElement>\)=>void | | Optional button click handler. Call `event.preventDefault()` to prevent toggling on click. |
91+
92+
All valid button attributes (except `children`) are forwarded to the underlying button element.
7893

7994
### Default Animation Properties
8095

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"src"
1010
],
1111
"engines": {
12-
"node": ">=10"
12+
"node": ">=20"
1313
},
1414
"scripts": {
1515
"start": "tsdx watch",

0 commit comments

Comments
 (0)