export const title = "Notification components" export const description = "Powerful and customizable React notification components built for modern applications and websites. These notifications are built using Sonner and styled with Tailwind CSS." export const links = { sonner: "https://sonner.emilkowal.ski/", } import * as Demos from "@/components/application/notifications/notifications.demo.tsx"; export const Hint = () => (

Click to trigger a toast

); ## Installation You can add this notifications component using our CLI or manually: ```bash npx untitledui add notifications ``` As our notifications component is built with [Sonner](https://sonner.emilkowal.ski/), you'll need to install the dependencies: ```bash npm install sonner ``` Copy the files below into your project: Great! Now you can start using the notifications components in your project by just copy/pasting our examples below. ## Notifications examples Below are examples and variations of this notifications component: ### Icon default {{ tocOnly:true }} ### Icon gray {{ tocOnly:true }} ### Icon brand {{ tocOnly:true }} ### Icon error {{ tocOnly:true }} ### Icon warning {{ tocOnly:true }} ### Icon success {{ tocOnly:true }} ### Progress notification {{ tocOnly:true }} ### Image notification {{ tocOnly:true }} ### Avatar notification {{ tocOnly:true }} ## API reference ` once near the root of your app — `import { Toaster } from \"@/components/application/notifications/toaster\"` — then call `toast.custom((t) => toast.dismiss(t)} />)` from `sonner` wherever you need it. Pass Sonner options such as `duration` or `id` as the second argument to `toast.custom`.", }, { question: "What colors does IconNotification support?", answer: "The `color` prop accepts `\"default\"`, `\"brand\"`, `\"gray\"`, `\"error\"`, `\"warning\"` and `\"success\"`, and defaults to `\"default\"`. The color also picks the icon automatically — `InfoCircle` for `\"default\"`, `\"brand\"` and `\"gray\"`, `AlertCircle` for `\"error\"` and `\"warning\"`, and `CheckCircle` for `\"success\"` — and `\"default\"` renders the featured icon in the `modern` theme while the others use `outline`.", }, { question: "Can I use a custom icon in a notification?", answer: "Yes. Pass any icon component to the `icon` prop of `IconNotification` and it overrides the icon that `color` would otherwise select, for example `icon={UploadCloud02}` from `@untitledui/icons`.", }, { question: "How do I show upload progress inside a notification?", answer: "Pass a number to the `progress` prop of `IconNotification`. It renders a `ProgressBar` with a `\"{value}% uploaded...\"` label under the description. To animate it, keep the id returned by `toast.custom` and call `toast.custom(..., { id })` again with the updated `progress` value.", }, { question: "How do I customize the notification buttons?", answer: "Set `confirmLabel` with `onConfirm` for the primary link button and `dismissLabel` with `onClose` for the secondary one — `dismissLabel` defaults to `\"Dismiss\"`. Pass `hideDismissLabel` to drop the text dismiss button; the close icon button in the top-right corner is always rendered and also calls `onClose`.", }, { question: "Where do notifications appear, and are they responsive?", answer: "`Toaster`, `ToastsOverlay` and `DEFAULT_TOAST_POSITION` are all exported from `@/components/application/notifications/toaster`. `Toaster` renders Sonner at the `DEFAULT_TOAST_POSITION` constant, which is `\"bottom-right\"`, and sets a `--width` of 400px (`ImageNotification` overrides it to 496px). Below the `xs` breakpoint the notification goes full width and stacks its content vertically. `ToastsOverlay` draws the background gradient and supports `\"top-right\"`, `\"top-left\"`, `\"bottom-right\"` and `\"bottom-left\"`, so per-toast `position` options are handled too.", }, ]} />