Skip to content

Commit e19049b

Browse files
committed
fix(webapp): Toaster inherits the app theme
Sonner stamps data-theme="light" (its default) on the toast list; since the theme system remaps tokens by that attribute, every custom toast rendered light regardless of the page's theme.
1 parent 6172c7f commit e19049b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • apps/webapp/app/components/primitives

apps/webapp/app/components/primitives/Toast.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EnvelopeIcon, ExclamationCircleIcon, XMarkIcon } from "@heroicons/react/20/solid";
22
import { CheckCircleIcon } from "@heroicons/react/24/solid";
3+
import { useThemeMode } from "~/hooks/useThemeMode";
34
import { AgentMonoLogo } from "./AgentDotMatrix";
45
import { useSearchParams } from "@remix-run/react";
56
import { useEffect, useMemo } from "react";
@@ -17,6 +18,7 @@ const permanentToastDuration = 60 * 60 * 24 * 1000;
1718

1819
export function Toast() {
1920
const { toastMessage } = useTypedLoaderData<typeof loader>();
21+
const mode = useThemeMode();
2022
useEffect(() => {
2123
if (!toastMessage) {
2224
return;
@@ -41,7 +43,11 @@ export function Toast() {
4143
);
4244
}, [toastMessage]);
4345

44-
return <Toaster />;
46+
// Sonner stamps its own `data-theme` (default "light") on the toast list,
47+
// and the app's theme selectors remap tokens for ANY subtree carrying that
48+
// attribute — so an unthemed Toaster forces every toast light. Pass the app's
49+
// mode through so the attribute agrees with the page (classic paints as dark).
50+
return <Toaster theme={mode} />;
4551
}
4652

4753
export function useToast() {

0 commit comments

Comments
 (0)