@enapter/design-theme
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Enapter Design Theme Provider

Dark Theme

Modify [data-theme="dark"] attribute in <html> tag to change color palettes (light/dark mode) by using:

// Use this on the top of scripts
// to apply 'system' or 'dark' (if saved previously) theme.

initTheme();
// Use this in any place
// to toggle light/dark theme.

toggleTheme();
// Use this in any place
// to set light or dark theme manually.

setThemeLight();
setThemeDark();

Read more →

Astro.js

Install the Enapter Design Theme Astro Integration:

npm i @enapter/design-theme

astro.config.mjs

import { defineConfig } from "astro/config";

import tailwind from "@astrojs/tailwind";
import enapterTheme from "@enapter/design-theme/astro";

export default defineConfig({
    // ...
    integrations: [tailwind(), enapterTheme()],
})

AnyComponent.astro

<script is:inline>
    document
        .querySelectorAll("[data-id=toggle-dark-mode-button]")
        .forEach((btn) => {
            btn.addEventListener("click", toggleTheme);
        });
</script>

Readme

Keywords

Package Sidebar

Install

npm i @enapter/design-theme

Weekly Downloads

22

Version

0.1.2

License

MIT

Unpacked Size

5.41 kB

Total Files

5

Last publish

Collaborators

  • zmnv
  • enapteruser