Skip to content

Commit d18c88e

Browse files
committed
docs: add readme
1 parent 47b90a3 commit d18c88e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22

33
[![NPM version](https://img.shields.io/npm/v/astro-theme-toggle?color=a1b858&label=)](https://www.npmjs.com/package/astro-theme-toggle)
44

5+
Create a ripple-style theme toggle animation in your Astro project.
6+
7+
## Installation
8+
9+
```bash
10+
npm install astro-theme-toggle
11+
```
12+
13+
## Usage
14+
15+
1. In your `<head>`, import the `theme-style.astro` component:
16+
17+
```astro
18+
---
19+
import ThemeStyle from 'astro-theme-toggle/theme-style.astro';
20+
---
21+
<head>
22+
<meta charset="utf-8" />
23+
<meta name="viewport" content="width=device-width,initial-scale=1" />
24+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
25+
<ThemeStyle />
26+
<!-- other head elements -->
27+
</head>
28+
```
29+
30+
2. Add a button to your `<body>` to toggle the theme:
31+
32+
```astro
33+
<button class="size-6" id="theme-toggle">
34+
<span class="i-ph-sun dark:i-ph-moon size-6 inline-block"></span>
35+
</button>
36+
<script>
37+
import { handleToggleClick } from 'astro-theme-toggle'
38+
document
39+
.getElementById('theme-toggle')
40+
?.addEventListener('click', handleToggleClick)
41+
</script>
42+
```
43+
44+
## Live Examples
45+
46+
- [Astrobook](https://astrobook.com)
47+
548
## License
649

750
MIT

0 commit comments

Comments
 (0)