Skip to main content

ToastLevel

TypeScript type representing the severity level of a toast notification.
This type corresponds to the PHP ToastLevel enum values. See the Enums page for more details.

ToastMessage

Represents a single toast notification message with its properties.

Properties

string
required
The main content of the toast notification.
ToastLevel
required
The severity level of the toast. Must be one of: 'success', 'error', 'info', or 'warning'.
string | null
required
Optional title displayed above the message. Pass null if no title is needed.
number | null
required
Custom duration in milliseconds for this specific toast. If null, uses the default duration from ToastConfig.

Source

Usage example


ToastItem

Extends ToastMessage with a unique identifier. Used internally by the Toaster component to track individual toasts.

Properties

Inherits all properties from ToastMessage:
string
required
Unique identifier for the toast. Generated automatically by the Toaster component.
string
required
The main content of the toast notification (inherited from ToastMessage).
ToastLevel
required
The severity level of the toast (inherited from ToastMessage).
string | null
required
Optional title displayed above the message (inherited from ToastMessage).
number | null
required
Custom duration in milliseconds (inherited from ToastMessage).

Source

Usage example

You typically don’t need to create ToastItem objects manually. The Toaster component automatically generates IDs for incoming ToastMessage objects.

ToastConfig

Configuration object for the Toaster component. Defines global settings for toast behavior and appearance.

Properties

number
required
Default duration in milliseconds for all toasts. Can be overridden per toast using ToastMessage.duration.Default: 3000
string
required
Screen position where toasts appear. Must be one of: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', or 'bottom-center'.Default: 'top-right'
number
required
Maximum number of toasts that can be visible simultaneously. Older toasts are dismissed when the limit is reached.Default: 3
string
required
The Inertia prop key used to receive toast messages from the backend.Default: 'toasts'

Source

Usage examples

The configuration values are set in config/inertia-toast.php and automatically passed to the frontend. You can override them by passing props to the Toaster component.

Type locations

Both Vue and React packages share identical TypeScript interfaces:
  • Vue: @inertiatoast/vue/src/types.ts
  • React: @inertiatoast/react/src/types.ts
You can import them using: