Binhlaig logoBinhlaig UI
Binhlaig UI Component

Toast

Lightweight floating notifications inspired by the clean interaction style of react-hot-toast, adapted for Binhlaig UI.

Installation

Install Toast in your project.

Terminal
npx binhlaig-ui@latest add toast

For project setup, installer selection, dependencies, and advanced installation instructions, see the Installation Guide.

View Installation Guide →Update or Overwrite →

Setup

Wrap the application with ToastProvider and render one Toaster.

import type { ReactNode } from "react"
import { ToastProvider, Toaster } from "@/components/ui/toast"

export default function RootLayout({ children }: { children: ReactNode }) {
  return (
    <html lang="en">
      <body>
        <ToastProvider>
          {children}
          <Toaster position="top-center" className="[&_.leading-5]:leading-8" />
        </ToastProvider>
      </body>
    </html>
  )
}

Import

import {
  ToastProvider,
  Toaster,
  useToast,
} from "@/components/ui/toast"

Basic

Show a lightweight toast with a title and optional description.

Variants

Built-in helpers for success, error, loading and info notifications.

Position

Place the toaster in any common screen corner or center position.

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

export function PositionedToaster() {
  return <Toaster position="top-right" />
}

// Alternative positions: bottom-center, bottom-right, top-left, top-center, bottom-left

Loading and Dismiss

Loading toasts stay visible until they are dismissed manually.

API Reference

APIPurpose
ToastProviderStores and manages toast state.
ToasterRenders the floating toast stack.
useToast()Access toast helpers.
toast()Show a default/custom toast.
success()Show a success toast.
error()Show an error toast.
loading()Show a persistent loading toast.
info()Show an informational toast.
dismiss(id?)Dismiss one toast or all toasts.