Skip to Content

toaster

ui

A toaster component to render toast notifications.

Source Code

View the full component source code below.

'use client'

import { useToast } from '@/hooks/use-toast'
import {
  Toast,
  ToastClose,
  ToastDescription,
  ToastProvider,
  ToastTitle,
  ToastViewport,
} from '@/components/ui/toast'

export function Toaster() {
  const { toasts } = useToast()

  return (
    <ToastProvider>
      {toasts.map(function ({ id, title, description, action, ...props }) {
        return (
          <Toast key={id} {...props}>
            <div className="grid gap-1">
              {title && <ToastTitle>{title}</ToastTitle>}
              {description && (
                <ToastDescription>{description}</ToastDescription>
              )}
            </div>
            {action}
            <ToastClose />
          </Toast>
        )
      })}
      <ToastViewport />
    </ToastProvider>
  )
}

Installation

npx shadcn@latest add https://registry.mukoko.com/api/v1/ui/toaster

Dependencies

API

Fetch this component's metadata and source code from the registry API.

GET/api/v1/ui/toaster

Source

components/ui/toaster.tsx