Skip to content

Commit eecec44

Browse files
Update dark mode section (#108)
<!-- If this pull request closes an issue, please mention the issue number below --> Closes # <!-- Issue # here --> ## 💸 TL;DR <!-- What's the three sentence summary of purpose of the PR --> The UI Simulator color scheme toggle temporarily forces the color scheme of the webview dialog, overriding the user's reddit theme to enable the dev to view their app in light and dark mode. This only works if the app has colors set for dark mode. Previous docs version only provided an example of doing this via CSS media query; this PR just adds an example of using Tailwind's `dark` class, which is essentially the same thing, but aligns more with our app templates. (All our app templates should already have this dark class built in to the basic UI, and devs will need to add it to all additional UI) Also added a note that the color scheme toggle does not currently work in Safari. ## 📜 Details [Design Doc](<!-- insert Google Doc link here if applicable -->) [Jira](<!-- insert Jira link if applicable -->) <!-- Add additional details required for the PR: breaking changes, screenshots, external dependency changes --> ## 🧪 Testing Steps / Validation <!-- add details on how this PR has been tested, include reproductions and screenshots where applicable --> ## ✅ Checks <!-- Make sure your pr passes the CI checks and do check the following fields as needed - --> - [ ] CI tests (if present) are passing - [ ] Adheres to code style for repo - [ ] Contributor License Agreement (CLA) completed if not a Reddit employee <img width="488" height="718" alt="Screenshot 2026-05-13 at 11 16 29 AM" src="https://github.com/user-attachments/assets/937b6ddd-7c10-4f1e-bd52-1ccb64c8660a" /> --------- Co-authored-by: Stacy <143668017+stacy-qqq@users.noreply.github.com>
1 parent 968cf86 commit eecec44

3 files changed

Lines changed: 91 additions & 1 deletion

File tree

docs/guides/tools/ui_simulator.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,39 @@ Example of how to use a CSS media query to set different colors for light and da
8484
}
8585
}
8686
```
87+
88+
89+
# Adding dark mode support
90+
91+
Devvit webviews automatically receive the user's color scheme preference (light or dark) from the Reddit app. To make your app respond to these changes, you need to add dark mode styles using either a CSS media query or Tailwind's `dark:` variant.
92+
93+
:::info
94+
Note: the UI simulator color scheme toggle does not currently work in Safari. This is a known issue due to browser limitations. Please use a Chrome-based browser to access this functionality while we work on a fix.
95+
:::
96+
97+
Example of how to use a CSS media query to set different colors for light and dark mode:
98+
99+
```css
100+
/* Light mode (default) */
101+
:root {
102+
--bg-color: #ffffff;
103+
--text-color: #000000;
104+
}
105+
106+
/* Dark mode */
107+
@media (prefers-color-scheme: dark) {
108+
:root {
109+
--bg-color: #000000;
110+
--text-color: #ffffff;
111+
}
112+
}
113+
```
114+
115+
Example of how to use Tailwind's `dark:` class:
116+
```tsx
117+
/* Before: Only light mode */
118+
<div className="bg-white text-black" />
119+
120+
/* After: Light + dark mode */
121+
<div className="bg-white dark:bg-black text-black dark:text-white" />
122+
```

versioned_docs/version-0.11/ui_simulator.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,39 @@ Example of how to use a CSS media query to set different colors for light and da
8787
}
8888
}
8989
```
90+
91+
92+
# Adding Dark Mode Support to Your Devvit App
93+
94+
Devvit webviews automatically receive the user's color scheme preference (light or dark) from the Reddit app. To make your app respond to these changes, you need to add dark mode styles using either a CSS media query or Tailwind's `dark:` variant.
95+
96+
:::info
97+
Note: the UI simulator color scheme toggle does not currently work in Safari. This is a known issue due to browser limitations. Please use a Chrome-based browser to access this functionality while we work on a fix.
98+
:::
99+
100+
Example of how to use a CSS media query to set different colors for light and dark mode:
101+
102+
```css
103+
/* Light mode (default) */
104+
:root {
105+
--bg-color: #ffffff;
106+
--text-color: #000000;
107+
}
108+
109+
/* Dark mode */
110+
@media (prefers-color-scheme: dark) {
111+
:root {
112+
--bg-color: #000000;
113+
--text-color: #ffffff;
114+
}
115+
}
116+
```
117+
118+
Example of how to use Tailwind's `dark:` class:
119+
```tsx
120+
/* Before: Only light mode */
121+
<div className="bg-white text-black" />
122+
123+
/* After: Light + dark mode */
124+
<div className="bg-white dark:bg-black text-black dark:text-white" />
125+
```

versioned_docs/version-0.12/guides/tools/ui_simulator.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,16 @@ Always test your app in mobile view first to validate that all critical features
6565
- Test all new features in mobile view before desktop
6666
- Verify both dark and light mode appearances
6767

68-
Remember: Mobile users are your primary audience. If it works well on mobile, it will likely work well everywhere else.
68+
Remember: Mobile users are your primary audience. If it works well on mobile, it will likely work well everywhere else.
69+
70+
71+
# Adding dark mode support
72+
73+
Devvit webviews automatically receive the user's color scheme preference (light or dark) from the Reddit app. To make your app respond to these changes, you need to add dark mode styles using either a CSS media query or Tailwind's `dark:` variant.
74+
75+
:::info
76+
Note: the UI simulator color scheme toggle does not currently work in Safari. This is a known issue due to browser limitations. Please use a Chrome-based browser to access this functionality while we work on a fix.
77+
:::
6978

7079
Example of how to use a CSS media query to set different colors for light and dark mode:
7180

@@ -84,3 +93,12 @@ Example of how to use a CSS media query to set different colors for light and da
8493
}
8594
}
8695
```
96+
97+
Example of how to use Tailwind's `dark:` class:
98+
```tsx
99+
/* Before: Only light mode */
100+
<div className="bg-white text-black" />
101+
102+
/* After: Light + dark mode */
103+
<div className="bg-white dark:bg-black text-black dark:text-white" />
104+
```

0 commit comments

Comments
 (0)