UILab

Sonner

An opinionated toast component for React.

"use client"

import { Button } from "uilab-core"
import { toast } from "sonner"

Installation

Install via following command:

Reminder

Following CLI command will install next-themes and sonner libraries to your project.

npx shadcn add @uilab-core/sonner

Add the Toaster component

app/layout.tsx
import { Toaster } from "uilab-core"

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head />
      <body>
        <Toaster />
        <main>{children}</main>
      </body>
    </html>
  )
}

Usage

import { toast } from "sonner"
toast("Event has been created.")

Examples

Types

"use client"

import { Button } from "uilab-core"
import { toast } from "sonner"

Description

"use client"

import { Button } from "uilab-core"
import { toast } from "sonner"

Position

Use the position prop to change the position of the toast.

"use client"

import { Button } from "uilab-core"
import { toast } from "sonner"

On this page