Web TippsUse custom web fonts in Google Sheets charts(08.09.2026 um 17:05 Uhr)
Web TippsIntroducing the new 1Password App for Google Chat(08.09.2026 um 18:02 Uhr)
Web TippsUse custom web fonts in Google Sheets charts(08.09.2026 um 17:05 Uhr)
Web TippsIntroducing the new 1Password App for Google Chat(08.09.2026 um 18:02 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 2 Min Lesezeit
0

How to Set Up sonner in Your React Project

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

If you're a developer who is confused about using the sonner library, follow the steps below to get it working.






Step 1: Install the Package



First, install the package in your project using npm or yarn:




CODE
npm install sonner






or




CODE
yarn add sonner









Step 2: Add the Styles



Next, add the necessary CSS for styling the toasts. You can copy the content from the official styles.css file here: https://github.com/emilkowalski/sonner/blob/main/src/styles.css



Save this file in your project, for example, at /src/styles/sonner.css, and make sure to import it into your parent App.




CODE
....
import "./styles/app.css";
import "./styles/sooner.css";









Step 3: Add the <Toaster /> Component



Then, add the <Toaster /> component to the root of your application so it can be rendered on any page.



For example, in a Remix application, you can add it to your app/root.tsx file within the Layout component. Make sure to import it first.




CODE
import { Toaster } from 'sonner';

export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
{children}
{/* Add the Toaster component here */}
<Toaster position="top-center" richColors />
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}









Step 4: Trigger a Toast



Finally, you can trigger a toast from any component. Import the toast function and call it from an event handler, like a button click.




CODE
import { toast } from 'sonner';

function MyComponent() {
//....
useEffect(() => {
if(errors.input){
toast.error(errors.input)
}
},[errors])

return (
<button onClick={() => toast("A toast has appeared!")}>
Show Toast
</button>
);
}









Customization: Enable Rich Colors



To enable colorful toasts for different types (like success, error, or warning), add the richColors prop to the <Toaster /> component, as shown in the Step 3 example.



If you run into any trouble, let me know in the comments below.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
Use custom web fonts in Google Sheets charts
2 Quellen
Introducing the new 1Password App for Google Chat
1 Quelle
Context-aware access controls are available for Gemini Enterprise in the Admin console
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Set Up sonner in Your React Project

Thematisch verwandte Begriffe: sonner, Your, React, Project · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...