Skip to main content

Overview

Solid Toast provides five built-in toast types, each optimized for different notification scenarios. Each type has its own default styling, icons, and duration.

Type Definition

type ToastType = 'success' | 'error' | 'loading' | 'blank' | 'custom';

Blank Toast

The default toast type with no icon or special styling.
import { toast } from 'solid-toast';

// Implicit blank type
toast('This is a blank toast');

// Explicit blank type
toast.blank('This is also a blank toast');
Blank toasts are perfect for simple informational messages that don’t require special emphasis.

Success Toast

Indicates a successful operation with a checkmark icon.
toast.success('Data saved successfully!');

// With custom options
toast.success('Profile updated', {
  duration: 3000,
  position: 'bottom-center',
});
Success toasts have a shorter default duration (2s) since positive feedback often doesn’t need to persist as long.

Error Toast

Indicates a failed operation with an error icon.
toast.error('Failed to save data');

// With error details
toast.error('Network error: Please check your connection');

// With custom styling
toast.error('Critical error', {
  duration: 6000,
  style: {
    background: '#dc2626',
    color: 'white',
  },
});
Error toasts should be clear and actionable. Include context about what failed and ideally how to fix it.

Loading Toast

Shows a loading spinner for ongoing operations.
// Create loading toast
const id = toast.loading('Loading...');

// Update when done
fetchData().then(() => {
  toast.success('Data loaded', { id });
});

// Or dismiss on error
fetchData().catch(() => {
  toast.error('Failed to load', { id });
});
Loading toasts persist indefinitely by default. Always update or dismiss them when the operation completes.

Custom Toast

Provides full control over toast content and styling.
toast.custom((t) => (
  <div class="my-custom-toast">
    <h3>Custom Notification</h3>
    <p>This is completely custom</p>
    <button onClick={() => toast.dismiss(t.id)}>Close</button>
  </div>
));

// With JSX element
toast.custom(
  <div class="custom-alert">
    <strong>Alert!</strong> Something happened.
  </div>
);
Custom toasts don’t include default styling. You’re responsible for all layout, colors, and interactions.

Type Comparison

TypeDurationIconCommon Use Case
blank4000msNoneGeneral notifications
success2000msCheckmarkSuccessful operations
error4000msError iconFailed operations
loadingInfinitySpinnerOngoing processes
custom4000msCustomUnique designs

Choosing the Right Type

  • General information that doesn’t fit other categories
  • Neutral announcements
  • Tips or suggestions
  • Non-critical updates
toast('New messages available');
toast('Autosave enabled');
  • Confirming user actions
  • Successful API calls
  • Completed tasks
  • Positive feedback
toast.success('Changes saved');
toast.success('Email sent');
  • Failed operations
  • Validation errors
  • Network issues
  • Permission denials
toast.error('Invalid email format');
toast.error('Connection timeout');
  • File uploads/downloads
  • API requests
  • Data processing
  • Any operation that takes time
const id = toast.loading('Uploading...');
// Update when complete
toast.success('Upload complete', { id });
  • Branded notifications
  • Complex layouts
  • Interactive toasts
  • Unique designs not covered by other types
toast.custom(<MyCustomComponent />);

See Also

Build docs developers (and LLMs) love