GitXplorerGitXplorer
o

astro-theme-toggle

public
24 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
8a07385bbae9e5f150aa743da10917d8da146d25

chore(master): release 0.5.0 (#18)

ggithub-actions[bot] committed 2 days ago
Verified
72dc1bff567c315ae859c24cf429d468ff524e96

feat: add `Toggle` component with default icons (#17)

oocavue committed 2 days ago
Verified
e704393c6195c1785786ca9500935df6d0f60348

chore(master): release 0.4.0 (#16)

ggithub-actions[bot] committed 2 days ago
Verified
c5e69b8ad5bb2c5cbb8629ed5e00d96f0e5b91d2

feat: set data-theme attribute (#15)

oocavue committed 2 days ago
Verified
5e93245ed6e5455848f31c4d791f49c1e484772b

chore(master): release 0.3.5 (#14)

ggithub-actions[bot] committed 3 months ago
Verified
bdc0ef0896e7b6afcc324f76e534bee8d5629d15

fix: support Astro's built-in view transitions (#13)

oocavue committed 3 months ago

README

The README file for this repository.

NPM version

Add a ripple-style theme toggle animation to your Astro project with ease.

https://github.com/user-attachments/assets/19069840-629d-445b-82e7-aea142242225

Installation

npm install astro-theme-toggle

Usage

  1. Add the ThemeScript component to your <head>. This will set the data-theme attribute and toggle the dark class on your <html> element based on the user's theme preference.

    ---
    import { ThemeScript } from 'astro-theme-toggle';
    ---
    <head>
      <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width,initial-scale=1" />
      <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
      <ThemeScript />
      <!-- other head elements -->
    </head>
  2. Add the Toggle component to your <body> to toggle the theme:

    ---
    import { Toggle } from 'astro-theme-toggle'
    ---
    
    <Toggle style="width: 32px; height: 32px;" />
  3. You can customize the icon by passing a Fragment with the icon-light and icon-dark slots.

    ---
    import { Toggle } from 'astro-theme-toggle'
    import MyLightIcon from './my-light-icon.astro'
    import MyDarkIcon from './my-dark-icon.astro'
    ---
    
    <Toggle style="width: 32px; height: 32px;">
      <Fragment slot="icon-light">
        <MyLightIcon />
      </Fragment>
      <Fragment slot="icon-dark">
        <MyDarkIcon />
      </Fragment>
    </Toggle>

Live Examples

License

MIT