Files
zeekay 16c4453cc1 feat: sync with upstream shadcn/ui (through [email protected])
Squash merge of shadcn-ui/ui main branch into hanzo/ui, bringing in:
- [email protected] through [email protected] releases
- New apps/v4 directory structure
- Registry system improvements and MCP server
- Framework support (Vue, Svelte, React Native)
- New templates (vite-app, monorepo-next, laravel)
- Zod 4 compatibility (scoped override for zod@>4)
- Test fixture corrections for alias resolution

All 867 merge conflicts resolved preserving Hanzo customizations.
1020/1020 shadcn tests pass.
2026-02-09 10:44:26 -08:00

127 lines
2.2 KiB
Plaintext

---
title: Sonner
description: An opinionated toast component for React.
base: radix
component: true
links:
doc: https://sonner.emilkowal.ski
---
<ComponentPreview styleName="radix-nova" name="sonner-demo" />
## About
Sonner is built and maintained by [emilkowalski](https://twitter.com/emilkowalski).
## Installation
<CodeTabs>
<TabsList>
<TabsTrigger value="cli">Command</TabsTrigger>
<TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">
<Steps className="mb-0 pt-2">
<Step>Run the following command:</Step>
```bash
npx shadcn@latest add sonner
```
<Step>Add the Toaster component</Step>
```tsx title="app/layout.tsx" {1,9} showLineNumbers
import { Toaster } from "@/components/ui/sonner"
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<main>{children}</main>
<Toaster />
</body>
</html>
)
}
```
</Steps>
</TabsContent>
<TabsContent value="manual">
<Steps className="mb-0 pt-2">
<Step>Install the following dependencies:</Step>
```bash
npm install sonner next-themes
```
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource
name="sonner"
title="components/ui/sonner.tsx"
styleName="radix-nova"
/>
<Step>Add the Toaster component</Step>
```tsx showLineNumbers title="app/layout.tsx" {1,8}
import { Toaster } from "@/components/ui/sonner"
export default function RootLayout({ children }) {
return (
<html lang="en">
<head />
<body>
<Toaster />
<main>{children}</main>
</body>
</html>
)
}
```
</Steps>
</TabsContent>
</CodeTabs>
## Usage
```tsx
import { toast } from "sonner"
```
```tsx
toast("Event has been created.")
```
## Examples
### Types
<ComponentPreview styleName="radix-nova" name="sonner-types" />
### Description
<ComponentPreview styleName="radix-nova" name="sonner-description" />
### Position
Use the `position` prop to change the position of the toast.
<ComponentPreview styleName="radix-nova" name="sonner-position" />
## API Reference
See the [Sonner API Reference](https://sonner.emilkowal.ski/getting-started) for more information.