-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathThemeSwitch.astro
More file actions
33 lines (30 loc) · 796 Bytes
/
ThemeSwitch.astro
File metadata and controls
33 lines (30 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
import { MoonIcon, SunIcon } from '@lucide/astro'
import styles from './ThemeSwitch.module.css'
---
<theme-switch
class={styles.themeSwitch}
title="Toggle Theme"
id="theme-toggle"
role="switch"
>
<label for="toggle" class={styles.checkbox}>
<span class="screenreader-only">Toggle Theme</span>
<input
type="checkbox"
name="toggle"
id="toggle"
aria-describedby="theme-toggle"
class="screenreader-only"
>
<div aria-live="assertive">
<SunIcon width={24} height={24} id="sun"/>
<MoonIcon width={24} height={24} id="moon" style="display: none;"/>
</div>
</label>
</theme-switch>
<script src="./theme-switch-element.ts"></script>
<script>
import { addThemeListeners } from '../lib/theme'
addThemeListeners()
</script>