Sonner
Toast notifications themed by your app's CSS tokens. A framework-agnostic Toaster with no next-themes dependency.
registry/onchain-ui/sonner.tsx
"use client";
import { Toaster as Sonner, type ToasterProps } from "sonner";
import {
CircleCheckIcon,
InfoIcon,
TriangleAlertIcon,
OctagonXIcon,
Loader2Icon,
} from "lucide-react";
import type { CSSProperties } from "react";
/**
* Toast surface colors come from your app's CSS tokens (`--popover`,
* `--border`, …), so this Toaster follows class-based and attribute-based
* dark modes with no theme library involved — unlike the stock shadcn item,
* there is no next-themes dependency here.
*
* The `theme` prop only drives sonner's built-in palette, which the token
* variables above already override; pass your app's resolved theme if you
* ever remove those overrides.
*/
const Toaster = ({ theme = "system", ...props }: ToasterProps) => {
return (
<Sonner
theme={theme}
className="toaster group"
icons={{
success: <CircleCheckIcon className="size-4" />,
info: <InfoIcon className="size-4" />,
warning: <TriangleAlertIcon className="size-4" />,
error: <OctagonXIcon className="size-4" />,
loading: <Loader2Icon className="size-4 animate-spin" />,
}}
style={
{
"--normal-bg": "var(--popover)",
"--normal-text": "var(--popover-foreground)",
"--normal-border": "var(--border)",
"--border-radius": "var(--radius)",
} as CSSProperties
}
{...props}
/>
);
};
export { Toaster };
No selection tags yet — empty means no evidence, not lack of support.
DependenciesBundle weight · light
- toasts
- sonner
- icons
- lucide-react