# Toast (/docs/components/toast)



<ComponentPreview name="toast-demo" />

## Overview [#overview]

Use Toast for short feedback that appears after an action.

Toasts are useful for saves, copies, uploads, background tasks, and lightweight errors. They should not contain information the user must act on later.

LoveUI includes two toast styles:

* **Toast:** a standard, quiet notification built on Base UI.
* **Gooey Toast:** an animated notification with morphing transitions and more expressive motion.

## Anatomy [#anatomy]

A toast has a title or message, optional description, status, optional action, and duration. A provider or toaster renders the stack of active toasts.

## Behavior [#behavior]

Use status to match the result. Use promise helpers when an async action has loading, success, and error states.

Use the standard Toast when the interface should feel calm and utilitarian. Use Gooey Toast when the notification is part of a more animated product moment, such as uploads, saves, confirmations, and async progress.

## Accessibility [#accessibility]

Keep messages short and clear. Important errors should also appear near the affected form or content, not only in a toast.

## Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTab value="cli">
      CLI
    </TabsTab>

    <TabsTab value="manual">
      Manual
    </TabsTab>
  </TabsList>

  <TabsPanel value="cli">
    ```bash
    npx love-ui@latest add toast
    ```

    <Step>
      Add the 

      `ToastProvider`

       to your app.
    </Step>

    <span data-lib="base-ui">
      ```tsx title="app/layout.tsx"
      // [!code word:import { ToastProvider } from "@/components/ui/toast"]
      // [!code word:<ToastProvider>]
      // [!code word:</ToastProvider>]
      import { ToastProvider } from "@/components/ui/toast"

      export default function RootLayout({ children }) {
        return (
          <html lang="en">
            <head />
            <body>
              <ToastProvider>
                <main>{children}</main>
              </ToastProvider>
            </body>
          </html>
        )
      }
      ```
    </span>
  </TabsPanel>

  <TabsPanel value="manual">
    <Steps>
      <Step>
        Install the following dependencies:
      </Step>

      ```bash
      npm install @base-ui-components/react
      ```

      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource name="toast" title="components/ui/toast.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>

      <Step>
        Add the 

        `ToastProvider`

         to your app.
      </Step>

      <span data-lib="base-ui">
        ```tsx title="app/layout.tsx"
        // [!code word:import { ToastProvider } from "@/rcomponents/ui/toast"]
        // [!code word:<ToastProvider>]
        // [!code word:</ToastProvider>]
        import { ToastProvider } from "@/components/ui/toast"

        export default function RootLayout({ children }) {
          return (
            <html lang="en">
              <head />
              <body>
                <ToastProvider>
                  <main>{children}</main>
                </ToastProvider>
              </body>
            </html>
          )
        }
        ```
      </span>
    </Steps>
  </TabsPanel>
</CodeTabs>

## Usage [#usage]

```tsx
import { toastManager } from "@/components/ui/toast"
```

```tsx
toastManager.add({
  title: "Event has been created",
  description: "Monday, January 3rd at 6:00pm",
})
```

By default, toasts appear in the **bottom-right** corner. You can change this by setting the `position` prop on the `ToastProvider`.

Allowed values: `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right`. For example:

```tsx
<ToastProvider position="top-center">{children}</ToastProvider>
```

Use the `variant` option to show the animated gooey variation from the same toast API:

```tsx
toastManager.add({
  variant: "gooey",
  title: "Event has been created",
  description: "Monday, January 3rd at 6:00pm",
})
```

You can combine `variant: "gooey"` with status types, actions, position, duration, and promise helpers.

```tsx
toastManager.add({
  variant: "gooey",
  type: "success",
  title: "Saved",
  description: "Your changes are live.",
  position: "top-right",
})
```

## Standard Toast Examples [#standard-toast-examples]

The examples show status, loading, actions, promise state, and varied toast heights.

### With Status [#with-status]

<ComponentPreview name="toast-with-status" />

### Loading [#loading]

<ComponentPreview name="toast-loading" />

### With Action [#with-action]

<ComponentPreview name="toast-with-action" />

### Promise [#promise]

<ComponentPreview name="toast-promise" />

### With Varying Heights [#with-varying-heights]

<ComponentPreview name="toast-heights" />

## Gooey Toast Usage [#gooey-toast-usage]

Gooey Toast is a variation of the Toast component. You do not install or render a separate provider.

By default, standard toasts appear in the **bottom-right** corner. Gooey toasts appear in the **top-right** corner unless you pass a `position` option.

Allowed values: `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right`.

```tsx
toastManager.add({
  variant: "gooey",
  position: "bottom-center",
  title: "Synced",
  description: "All records are up to date.",
})
```

## Gooey Toast Examples [#gooey-toast-examples]

These examples show the animated toast style, state variants, promise handling, action buttons, and placement.

### Basic Gooey Toast [#basic-gooey-toast]

<ComponentPreview name="gooey-toast-demo" />

### Gooey States [#gooey-states]

Gooey Toast supports success, error, warning, info, and action states.

<ComponentPreview name="gooey-toast-states" />

### Gooey Promise [#gooey-promise]

Drive gooey toast states from promises for async operations.

<ComponentPreview name="gooey-toast-promise" />

### Gooey With Action Button [#gooey-with-action-button]

Add an interactive button to a gooey toast.

<ComponentPreview name="gooey-toast-with-button" />

### Gooey Position [#gooey-position]

Control where gooey toasts appear on the screen.

<ComponentPreview name="gooey-toast-position" />

## Gooey Toast API Reference [#gooey-toast-api-reference]

### `toastManager.add` [#toastmanageradd]

The same `toastManager.add` method shows both standard and gooey toasts.

Use no variant for a standard toast:

```tsx
toastManager.add({
  title: "Saved",
  description: "Your changes are live.",
})
```

Use `variant: "gooey"` for the animated variation:

```tsx
toastManager.add({
  variant: "gooey",
  type: "success",
  title: "Saved",
  description: "Your changes are live.",
})
```

### Gooey Options [#gooey-options]

```typescript
interface GooeyOptions {
  variant?: "gooey"
  title?: string
  description?: ReactNode | string
  position?: GooeyPosition
  duration?: number | null
  icon?: ReactNode | null
  styles?: GooeyStyles
  fill?: string
  roundness?: number
  autopilot?: boolean | { expand?: number; collapse?: number }
  button?: {
    title: string
    onClick: () => void
  }
}
```

### Toast Provider Props [#toast-provider-props]

```typescript
interface ToastProviderProps {
  position?: ToastPosition // Standard toast position
  gooeyPosition?: ToastPosition // Default position for gooey toasts
  gooeyOptions?: Partial<GooeyOptions>
}
```
