Skip to content

Commit dbad94c

Browse files
committed
docs: create dark-mode document
1 parent 4b77c29 commit dbad94c

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

website/app/docs.routes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const SidebarRoutes: iDocsRoutes[] = [
9696
routes: [
9797
{
9898
title: 'Dark Mode',
99-
path: '/docs/dark-mode',
99+
path: '/dark-mode',
100100
},
101101
],
102102
},

website/app/routes/dark-mode.mdx

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { siteTitle } from '../globals.ts';
2+
3+
export const meta = [
4+
{
5+
title: `Dark Mode - Customization | ${siteTitle}`,
6+
description: 'How to use @pheralb/toast library with next-themes (Next.js) or remix-themes (Remix)'
7+
},
8+
];
9+
10+
# Dark Mode
11+
12+
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.
13+
14+
## Next.js with next-themes
15+
16+
> [**Click here**](https://github.com/pacocoursey/next-themes?tab=readme-ov-file#install) to read the documentation.
17+
18+
Add ``ThemeProvider`` with [``ToastProvider``](/provider):
19+
20+
```tsx
21+
// 📄 app/layout.tsx
22+
23+
import { ThemeProvider } from "next-themes";
24+
import { ToastProvider } from "@pheralb/toast";
25+
26+
export default function RootLayout({
27+
children,
28+
}: Readonly<{ children: ReactNode }>) {
29+
return (
30+
<html lang="en">
31+
<body>
32+
<ThemeProvider
33+
attribute="class"
34+
defaultTheme="system"
35+
enableSystem
36+
disableTransitionOnChange
37+
>
38+
<ToastProvider>{children}</ToastProvider>
39+
</ThemeProvider>
40+
</body>
41+
</html>
42+
);
43+
}
44+
```
45+
46+
## Remix with remix-themes
47+
48+
> [**Click here**](https://github.com/abereghici/remix-themes?tab=readme-ov-file#getting-started) to read the documentation.
49+
50+
Import the ``useTheme`` hook from ``remix-themes`` and change the theme value:
51+
52+
```tsx
53+
// 📄 app/root.tsx
54+
55+
import {
56+
useTheme,
57+
} from 'remix-themes';
58+
59+
function App() {
60+
const [theme] = useTheme();
61+
return (
62+
<html lang="en" className={cn(theme)}>
63+
<head>
64+
<meta charSet="utf-8" />
65+
<meta name="viewport" content="width=device-width, initial-scale=1" />
66+
<Meta />
67+
<Links />
68+
</head>
69+
<body>
70+
<ToastProvider theme={theme!}>
71+
<Outlet />
72+
</ToastProvider>
73+
<ScrollRestoration />
74+
<Scripts />
75+
</body>
76+
</html>
77+
);
78+
}
79+
```

0 commit comments

Comments
 (0)