File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
[ ![ NPM version] ( https://img.shields.io/npm/v/astro-theme-toggle?color=a1b858&label= )] ( https://www.npmjs.com/package/astro-theme-toggle )
4
4
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
+
5
48
## License
6
49
7
50
MIT
You can’t perform that action at this time.
0 commit comments