Toast Options

Complete reference for all available toast configuration options.

ToastOptions Interface

The ToastOptions interface defines all available options when creating a toast.

interface ToastOptions {
  type?: "success" | "error" | "info" | "warning";
  title: string;
  description?: string;
  duration?: number;
  position?: Position;
  icon?: string;
  showIcon?: boolean;
  showProgress?: boolean;
  actions?: Action[];
  actionsLayout?: "horizontal" | "vertical";
  avatar?: Avatar;
  maxToasts?: number;
  ui?: UIOverrides;
}
interface Action {
  label: string;
  onClick: () => void;
}
interface Avatar {
  type?: "image" | "icon" | "text";
  src?: string; // image
  icon?: string; // icon
  text?: string; // text
}
interface UIOverrides {
  root?: string; // Toast container
  title?: string; // Title element
  description?: string; // Description element
  icon?: string; // Icon wrapper
  actions?: string; // Actions container
  action?: string; // Individual action button
  progress?: string; // Progress bar
  avatar?: string; // Avatar container
}

Core Options

type

Type: 'success' | 'error' | 'info' | 'warning'
Default: 'info'

The type of toast notification, which affects the default styling and icon.

<script setup>
const toast = useToast();

toast.add({ type: "success", title: "Success!" });
</script>
<script setup>
const toast = useToast();

toast.add({ type: "error", title: "Error!" });
</script>
<script setup>
const toast = useToast();

toast.add({ type: "info", title: "Info!" });
</script>
<script setup>
const toast = useToast();

toast.add({ type: "warning", title: "Warning!" });
</script>

title

Type: string
Required: Yes

The main heading text of the toast.

Title
<script setup>
const toast = useToast();

toast.success("Operation Complete");
</script>

description

Type: string
Default: undefined

Additional descriptive text displayed below the title.

With description
<script setup>
const toast = useToast();

toast.success("File Saved", "Your changes have been saved successfully");
</script>

duration

Type: number
Default: 5000

How long the toast remains visible in milliseconds. Set to Infinity for persistent toasts.

<script setup>
const toast = useToast();

toast.info("Quick message", "", { duration: 2000 });
</script>
<script setup>
const toast = useToast();

toast.info("Important", "Read carefully", { duration: 10000 });
</script>
<script setup>
const toast = useToast();

toast.warning("Critical", "Requires action", { duration: Infinity });
</script>

position

Type: 'top-right' | 'top-left' | 'top-center' | 'bottom-right' | 'bottom-left' | 'bottom-center'
Default: 'top-right'

Where the toast appears on screen.

<script setup>
const toast = useToast();

toast.info("Top Right", "", { position: "top-right" });
</script>
<script setup>
const toast = useToast();

toast.info("Bottom Center", "", { position: "bottom-center" });
</script>

Icon Options

icon

Type: string
Default: Type-specific default icon

Custom icon name from Nuxt Icon library.

Custom icon
<script setup>
const toast = useToast();

toast.add({
  type: "info",
  title: "Custom Icon",
  icon: "i-lucide-heart",
});
</script>

showIcon

Type: boolean
Default: true

Whether to display the icon.

Hide icon
<script setup>
const toast = useToast();

toast.success("No Icon", "", { showIcon: false });
</script>

Progress Option

showProgress

Type: boolean
Default: false

Display a progress bar showing remaining time.

Progress
<script setup>
const toast = useToast();

toast.info("Processing", "With progress bar", {
  showProgress: true,
  duration: 8000,
});
</script>

Actions

actions

Type: Action[]
Default: undefined

Array of action buttons to display.

Actions
<script setup>
const toast = useToast();

toast.add({
  type: "warning",
  title: "Confirm Delete",
  actions: [
    {
      label: "Delete",
      onClick: () => {
        console.log("Deleted");
      },
    },
    {
      label: "Cancel",
      onClick: () => {
        toast.clear();
      },
    },
  ],
});
</script>

actionsLayout

Type: 'horizontal' | 'vertical'
Default: 'horizontal'

How to arrange action buttons.

<script setup>
const toast = useToast();

toast.add({
  type: "info",
  title: "Choose Layout",
  actionsLayout: "vertical",
  actions: [
    { label: "Option 1", onClick: () => {} },
    { label: "Option 2", onClick: () => {} },
  ],
});
</script>
<script setup>
const toast = useToast();

toast.add({
  type: "info",
  title: "Choose Layout",
  actionsLayout: "horizontal",
  actions: [
    { label: "Option 1", onClick: () => {} },
    { label: "Option 2", onClick: () => {} },
  ],
});
</script>

Avatar

avatar

Type: Avatar
Default: undefined

Display an avatar in the toast.

Image avatar

Image avatar
<script setup>
const toast = useToast();

toast.add({
  type: "info",
  title: "John mentioned you",
  avatar: {
    type: "image",
    src: "https://i.pravatar.cc/150?img=12",
  },
});
</script>

Icon avatar

Icon avatar
<script setup>
const toast = useToast();

toast.add({
  type: "success",
  title: "Achievement",
  avatar: {
    type: "icon",
    icon: "i-lucide-trophy",
  },
});
</script>

Text avatar

Text avatar
<script setup>
const toast = useToast();

toast.add({
  type: "info",
  title: "Message from Sarah",
  avatar: {
    type: "text",
    text: "SK",
  },
});
</script>

Advanced Options

maxToasts

Type: number
Default: Global config value (default: 5)

Override the maximum number of visible toasts for this specific toast.

maxToasts
<script setup>
const toast = useToast();

toast.add({
  title: "Replace All",
  maxToasts: 1, // Only show this toast, clear all others
});
</script>

ui

Type: UIOverrides
Default: undefined

Override default styles with custom Tailwind CSS classes.

UI override
<script setup>
const toast = useToast();

toast.add({
  type: "success",
  title: "Custom Styling",
  description: "With Tailwind classes",
  ui: {
    root: "rounded-2xl border-2 border-dashed border-primary-500",
    title: "text-xl font-bold",
    description: "text-sm italic",
  },
});
</script>

Complete Example

Here's a toast using multiple options:

Complete example
<script setup>
const toast = useToast();

toast.add({
  type: "warning",
  title: "Review Required",
  description: "Your approval is needed for this design",
  duration: 10000,
  position: "top-right",
  showProgress: true,
  avatar: {
    type: "image",
    src: "https://i.pravatar.cc/150?img=5",
  },
  actions: [
    {
      label: "Approve",
      onClick: () => {
        toast.success("Approved", "Design has been approved");
      },
    },
    {
      label: "Reject",
      onClick: () => {
        toast.error("Rejected", "Design has been rejected");
      },
    },
  ],
  ui: {
    root: "shadow-xl ring-1 ring-black/5",
  },
});
</script>