Skip to content

lukonik/themer

Repository files navigation

Themer

Theme management for TanStack Router and TanStack Start.

NPM Version License

Docs

Full documentation is available at lukonik.github.io/themer.

Install

pnpm add @lonik/themer

Quick Usage

Wrap your app with ThemeProvider:

import { Outlet, createRootRoute } from "@tanstack/react-router";
import { ThemeProvider } from "@lonik/themer";

export const Route = createRootRoute({
  component: () => (
    <html lang="en" suppressHydrationWarning>
      <body>
        <ThemeProvider>
          <Outlet />
        </ThemeProvider>
      </body>
    </html>
  ),
});

Use useTheme to read and update the current theme:

import { useTheme } from "@lonik/themer";

export function ThemeToggle() {
  const { theme, setTheme } = useTheme();

  return (
    <button onClick={() => setTheme(theme === "dark" ? "light" : "dark")}>
      Current theme: {theme}
    </button>
  );
}

Example

<ThemeProvider
  themes={["light", "dark", "ocean"]}
  defaultTheme="system"
  storage="localStorage"
>
  <App />
</ThemeProvider>

For API details and guides, see the documentation site.

About

Theming library for tanstack start and router

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors