IndiaCN UI

Toast

A brief, non-intrusive notification that appears temporarily.

Introduction

Toasts deliver brief notifications to users without interrupting their workflow. They support multiple themes, auto-dismiss, and can be positioned anywhere on screen.

Installation

import { Toast, ToastTitle, ToastDescription, ToastContainer, ToastProvider, useToast } from '@/components/ui/toast';

Usage

<Toast onDismiss={() => {}}>
<ToastTitle>Notification</ToastTitle>
<ToastDescription>Your changes have been saved.</ToastDescription>
</Toast>

Examples

Default

ToastDefault
import { Toast, ToastTitle, ToastDescription } from '@/components/ui/toast';

export default function Component() {
  return (
    <Toast onDismiss={() => {}}>
      <ToastTitle>Notification</ToastTitle>
      <ToastDescription>This is a default toast message.</ToastDescription>
    </Toast>
  );
}

Themes

ToastThemes
import { Toast, ToastTitle, ToastDescription } from '@/components/ui/toast';

export default function Component() {
  return (
    <div className="flex w-full flex-col gap-3">
      <Toast theme="success" onDismiss={() => {}}><ToastTitle>Success</ToastTitle><ToastDescription>Done!</ToastDescription></Toast>
      <Toast theme="danger" onDismiss={() => {}}><ToastTitle>Error</ToastTitle><ToastDescription>Failed.</ToastDescription></Toast>
    </div>
  );
}

Simple

A toast without a title.

ToastSimple
import { Toast, ToastDescription } from '@/components/ui/toast';

export default function Component() {
  return <Toast><ToastDescription>Your file has been uploaded.</ToastDescription></Toast>;
}

API Reference

Toast

PropTypeDefaultDescription
themedefault | primary | success | danger | warningdefaultColor theme
onDismiss() => voidDismiss callback, shows close button

ToastContainer

PropTypeDefaultDescription
positiontop-left | top-right | top-center | bottom-left | bottom-right | bottom-centerbottom-rightScreen position

useToast

Hook for programmatic toast management. Returns { toast, dismiss, toasts }.

On this page