Y2K UI

Sonner (Toast)

A toast notification component wrapping the sonner library. Each toast renders as a mini Y2K window — pastel title bar with window dots, thick navy border, flat white body, and an ✕ close control.

sonner-demo.app

Installation

terminal.sh
npx y2kui@latest add sonner

You'll also need the sonner package installed in your project:

terminal.sh
npm install sonner

Usage

Place <Toaster /> once at the root of your app, then import toast anywhere to trigger notifications.

// app/layout.tsx — add <Toaster /> inside <body>
import { Toaster } from "@/components/ui/sonner"

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        {children}
        <Toaster />
      </body>
    </html>
  )
}

// Any client component
import { toast } from "sonner"

toast.success("Saved!")
toast.error("Something went wrong")
toast("Hello world")

Toast types

MethodTitle bar
toast(message)Plain white title bar
toast.success(message)Lemon title bar (#ffe45e)
toast.error(message)Pink title bar (#ff8fcf)
toast.info(message)Blue title bar (#8ed1fc)
toast.warning(message)Lilac title bar (#b69cff)

Each call accepts an options object as the second argument:

toast.success("Title", {
  description: "Additional detail shown below the body.",
  duration: 4000,
  action: {
    label: "Undo",
    onClick: () => console.log("Undo"),
  },
})

Props

The <Toaster /> component accepts all props supported by the underlying Sonner Toaster.

PropTypeDefaultDescription
closeButtonbooleantrueShow an ✕ close button in the title bar. Enabled by default in Y2K styling.
position'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center''bottom-right'Where toasts appear on screen.
durationnumber4000Time in ms before a toast auto-dismisses. Set to Infinity to disable.
expandbooleanfalseShow toasts in an expanded list.
visibleToastsnumber3Maximum number of visible toasts.
offsetnumber | string24pxOffset from the edge of the screen.
gapnumber12Gap between toasts in px.
toastOptionsToastOptionsOverride default styling or add per-toast className.
richColorsbooleanfalseUse Sonner's built-in rich colors (overrides Y2K styling).

On this page