JGuang / JGuang UI
Components组件Radix UIRadix UI 组件

Sonner

An opinionated toast component for React.

Partially translated: Chinese navigation, titles, descriptions, and common headings. The technical body is currently in English.
Loading JGuang UI example…

About

Sonner is built and maintained by emilkowalski.

Installation

Command

Manual

Run the following command:

Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.

Add the Toaster component

import { Toaster } from "@/components/ui/sonner"

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

Install the following dependencies:

npm install sonner next-themes

Copy and paste the following code into your project.

View complete source: components/ui/sonner.tsx

Add the Toaster component

import { Toaster } from "@/components/ui/sonner"

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.")

Types

Loading JGuang UI example…

Description

Loading JGuang UI example…

Position

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

Loading JGuang UI example…

API Reference

See the Sonner API Reference for more information.

Source: components/radix/sonner.mdx

Technical documentation for JGuang UI.

On this page