Skip to content

Commit

Permalink
docs: create dark-mode document
Browse files Browse the repository at this point in the history
  • Loading branch information
pheralb committed Jul 15, 2024
1 parent 4b77c29 commit dbad94c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion website/app/docs.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const SidebarRoutes: iDocsRoutes[] = [
routes: [
{
title: 'Dark Mode',
path: '/docs/dark-mode',
path: '/dark-mode',
},
],
},
Expand Down
79 changes: 79 additions & 0 deletions website/app/routes/dark-mode.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { siteTitle } from '../globals.ts';

export const meta = [
{
title: `Dark Mode - Customization | ${siteTitle}`,
description: 'How to use @pheralb/toast library with next-themes (Next.js) or remix-themes (Remix)'
},
];

# Dark Mode

By default, ``@pheralb/toast`` use the ``system`` theme (check [``ToastProvider``](/provider#theme)). This page shows examples of how to use [``next-themes`` (Next.js)](https://github.com/pacocoursey/next-themes) or [``remix-themes`` (Remix)](https://github.com/abereghici/remix-themes) libraries.

## Next.js with next-themes

> [**Click here**](https://github.com/pacocoursey/next-themes?tab=readme-ov-file#install) to read the documentation.
Add ``ThemeProvider`` with [``ToastProvider``](/provider):

```tsx
// 📄 app/layout.tsx

import { ThemeProvider } from "next-themes";
import { ToastProvider } from "@pheralb/toast";

export default function RootLayout({
children,
}: Readonly<{ children: ReactNode }>) {
return (
<html lang="en">
<body>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<ToastProvider>{children}</ToastProvider>
</ThemeProvider>
</body>
</html>
);
}
```

## Remix with remix-themes

> [**Click here**](https://github.com/abereghici/remix-themes?tab=readme-ov-file#getting-started) to read the documentation.
Import the ``useTheme`` hook from ``remix-themes`` and change the theme value:

```tsx
// 📄 app/root.tsx

import {
useTheme,
} from 'remix-themes';

function App() {
const [theme] = useTheme();
return (
<html lang="en" className={cn(theme)}>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<ToastProvider theme={theme!}>
<Outlet />
</ToastProvider>
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}
```

0 comments on commit dbad94c

Please sign in to comment.