toast
neobrutalui/toastFreeComponent
Show temporary notifications with automatic dismissal and optional actions.
Live preview
live · rendered by the registry
Rendered by neobrutalui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.neobrutalui.live/r/toast.jsonSource
1"use client"23import * as React from "react"4import { Toast as BaseToast } from "@base-ui/react/toast"5import { cn } from "@/lib/utils"67type ToastPosition =8 | "top-left"9 | "top-right"10 | "top-center"11 | "bottom-left"12 | "bottom-right"13 | "bottom-center"1415interface ToastOptions {16 title?: React.ReactNode17 description?: React.ReactNode18 timeout?: number19 priority?: "low" | "high"20 onClose?: () => void21 onRemove?: () => void22 actionProps?: React.ComponentPropsWithoutRef<"button">23}2425interface ToastPromiseOptions<Value> {26 loading: string | ToastOptions27 success: string | ToastOptions | ((result: Value) => string | ToastOptions)28 error: string | ToastOptions | ((error: unknown) => string | ToastOptions)29}3031type ToastProps = React.ComponentPropsWithoutRef<typeof BaseToast.Root>3233interface ToasterProps {34 position?: ToastPosition35}3637const VIEWPORT_POSITIONS: Record<ToastPosition, string> = {38 "top-left": "fixed top-4 left-4 z-50 w-full max-w-sm flex",39 "top-right": "fixed top-4 right-4 z-50 w-full max-w-sm flex",40 "top-center": "fixed top-4 left-1/2 -translate-x-1/2 z-50 w-full max-w-sm flex",41 "bottom-left": "fixed bottom-4 left-4 z-50 w-full max-w-sm flex",42 "bottom-right": "fixed bottom-4 right-4 z-50 w-full max-w-sm flex",43 "bottom-center": "fixed bottom-4 left-1/2 -translate-x-1/2 z-50 w-full max-w-sm flex",44}4546function getSwipeDirection(47 position: ToastPosition,48): ("up" | "down" | "left" | "right")[] {49 const isTop = position.startsWith("top")50 const isLeft = position.includes("left")51 const isCenter = position.includes("center")52 if (isCenter) return isTop ? ["up"] : ["down"]53 if (isLeft) return isTop ? ["up", "left"] : ["down", "left"]54 return isTop ? ["up", "right"] : ["down", "right"]55}5657const COMMON_TOAST_CLASSES = [58 "[--gap:0.75rem]",59 "[--peek:0.75rem]",60 "[--scale:calc(max(0,1-(var(--toast-index)*0.1)))]",61 "[--shrink:calc(1-var(--scale))]",62 "[--height:var(--toast-frontmost-height,var(--toast-height))]",63 "absolute w-full z-[calc(1000-var(--toast-index))]",64 "rounded-base border-2 bg-white bg-clip-padding p-6 pr-8 shadow-brutal select-none",65 "after:absolute after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",66 "data-ending-style:opacity-0",67 "data-limited:opacity-0",68 "h-(--height) data-expanded:h-(--toast-height)",69// … truncated
What it pulls in
npm packages
Other registry items
More from neobrutalui
All 24 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | neobrutalui | Components | Free | 2 deps | |
| alertalert | neobrutalui | Components | Free | 1 dep | |
| avataravatar | neobrutalui | Components | Free | no deps | |
| badgebadge | neobrutalui | Components | Free | 1 dep | |
| buttonbutton | neobrutalui | Components | Free | 1 dep | |
| cardcard | neobrutalui | Components | Free | no deps | |
| checkboxcheckbox | neobrutalui | Components | Free | 2 deps | |
| date-pickerdate-picker | neobrutalui | Components | Free | 2 deps |
