Componentfeedback1.49 KB gzipZero dependencies

Toast

Transient stacked notices with auto-dismiss.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add toast

Or install the full npm package:

npm install bigbullui

Usage

tsx10 lines
import { ToastProvider, useToast } from "@/components/ui/toast"; function Demo() {  const { toast } = useToast();  return (    <button onClick={() => toast({ title: "Admitted", description: "Stub #402 accepted." })}>      Show Toast    </button>  );}

Source code

toast.tsx + 2 helpers

Zero third-party dependencies (3 local files shown in tabs below).

tsxtoast.tsx221 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { useIsMounted } from "./lib/react-compat"; export type ToastTone = "default" | "accent" | "destructive";export type ToastPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left"; export interface ToastAction {  label: string;  onClick: () => void;} export interface ToastOptions {  title: string;  description?: string;

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { useToast } from "@/components/ui/toast"; <useToast />
PropTypeDescription
childrenReact.ReactNodeChild elements rendered inside the component.
positionToastPositionConfigures position. (Default: "bottom-right")
maxToastsnumberConfigures max toasts. (Default: 5)