(container, fixed position)
└── For (reactive list)
├── ToastContainer
│ └── ToastBar (if not custom type)
│ ├── Success/Error/Loader icon (if applicable)
│ └── message container
├── ToastContainer
│ └── custom JSX (if custom type)
└── ...
```
--------------------------------
### toast.error()
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/toast-function.md
Creates an error toast with an animated error icon.
```APIDOC
## toast.error(message, options)
### Description
Creates an error toast with an animated error icon.
### Parameters
- **message** (Message) - Required - Toast content as string, JSX element, or function
- **options** (ToastOptions) - Optional - Configuration object for customizing the toast
### Return
- **Type** (string) - Unique identifier for the created toast.
### Example
```typescript
import { toast } from 'solid-toast';
toast.error('Something went wrong!');
```
```
--------------------------------
### Show Simple Toast
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/README.md
Displays a basic text notification.
```typescript
toast('Operation complete');
```
--------------------------------
### Configure the Toaster component
Source: https://github.com/ardeora/solid-toast/blob/main/README.md
Set global defaults and container styles for all rendered toasts.
```jsx
```
--------------------------------
### toast(msg, opts?)
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/README.md
Displays a basic toast notification with an optional message and configuration options.
```APIDOC
## toast(msg, opts?)
### Description
Displays a standard toast notification. The `msg` parameter is the content to display, and `opts` is an optional configuration object for duration, position, and styling.
### Parameters
- **msg** (string|JSX.Element) - Required - The content to display in the toast.
- **opts** (object) - Optional - Configuration object including duration, position, style, className, icon, and iconTheme.
```
--------------------------------
### Define Toast Bar Base Styles
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/utility-functions.md
Base CSS properties for non-custom toast containers.
```typescript
const toastBarBase: JSX.CSSProperties = {
display: 'flex',
'align-items': 'center',
color: '#363636',
background: 'white',
'box-shadow': '0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)',
'max-width': '350px',
'pointer-events': 'auto',
padding: '8px 10px',
'border-radius': '4px',
'line-height': '1.3',
'will-change': 'transform',
}
```
--------------------------------
### Reacting to Store Changes
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/store.md
Uses createEffect to observe changes in the toast store state.
```typescript
import { store } from 'solid-toast';
import { createEffect } from 'solid-js';
createEffect(() => {
console.log(`Toast count: ${store.toasts.length}`);
console.log(`Paused: ${store.pausedAt !== undefined}`);
});
```
--------------------------------
### Create a custom toast with toast.custom()
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/toast-function.md
Defines the signature for the custom toast function.
```typescript
function custom(
component: (toast: Toast) => JSX.Element,
options?: DefaultToastOptions
): string
```
--------------------------------
### Customize Toaster
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/quick-start.md
Configure global settings for the Toaster component.
```typescript
```
--------------------------------
### toast.error(message, options)
Source: https://github.com/ardeora/solid-toast/blob/main/README.md
Creates an error toast with an animated error icon.
```APIDOC
## toast.error(message, options)
### Description
Creates a notification with an animated error icon. Color accents can be themed with the iconTheme option.
```
--------------------------------
### Customizing Icon Themes
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/icon-components.md
Configures icon colors globally for specific toast types using the iconTheme option.
```typescript
import { toast } from 'solid-toast';
toast.success('Success!', {
iconTheme: {
primary: '#06b6d4', // cyan
secondary: '#ecf0f1', // light gray
},
});
toast.error('Error!', {
iconTheme: {
primary: '#f97316', // orange
secondary: '#fed7aa', // light orange
},
});
toast.loading('Loading...', {
iconTheme: {
primary: '#8b5cf6', // purple
secondary: '#ede9fe', // light purple
},
});
```
--------------------------------
### Configure Toast Defaults
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/README.md
Default settings for individual toast notifications, including duration and accessibility properties.
```typescript
duration: {
success: 2000,
error: 4000,
loading: Infinity,
blank: 4000,
custom: 4000,
}
position: 'top-right'
unmountDelay: 500
ariaProps: { role: 'status', 'aria-live': 'polite' }
className: ''
style: {}
icon: ''
iconTheme: {}
```
--------------------------------
### ToastBar Animation Implementation
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/internal-components.md
Uses the Web Animations API to handle toast entry and exit animations based on visibility and position.
```typescript
createEffect(() => {
if (!el) return;
const direction = getToastYDirection(props.toast, props.position);
if (props.toast.visible) {
// Enter animation
el.animate(
[
{ transform: `translate3d(0,${direction * -200}%,0) scale(.6)`, opacity: 0.5 },
{ transform: 'translate3d(0,0,0) scale(1)', opacity: 1 },
],
{
duration: 350,
fill: 'forwards',
easing: 'cubic-bezier(.21,1.02,.73,1)'
}
);
} else {
// Exit animation
el.animate(
[
{ transform: 'translate3d(0,0,-1px) scale(1)', opacity: 1 },
{ transform: `translate3d(0,${direction * -150}%,-1px) scale(.4)`, opacity: 0 },
],
{
duration: 400,
fill: 'forwards',
easing: 'cubic-bezier(.06,.71,.55,1)'
}
);
}
});
```
--------------------------------
### ToastBar Rendered Structure
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/internal-components.md
The HTML structure and styling logic for the ToastBar component.
```html
{toast.icon ? (
toast.icon
) : toast.type === 'loading' ? (
) : toast.type === 'success' ? (
) : toast.type === 'error' ? (
) : null}
{resolveValue(toast.message, toast)}
```
--------------------------------
### Trigger Enter Animation for ToastBar
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/architecture.md
Executes a scale, slide, and fade-in animation when a toast becomes visible. The direction variable should be 1 for top positions and -1 for bottom.
```javascript
el.animate(
[
{
transform: `translate3d(0,${direction * -200}%,0) scale(.6)`,
opacity: 0.5
},
{
transform: 'translate3d(0,0,0) scale(1)',
opacity: 1
},
],
{
duration: 350,
fill: 'forwards',
easing: 'cubic-bezier(.21,1.02,.73,1)'
}
);
```
--------------------------------
### State Interface
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/types.md
Defines the complete state structure of the toast store.
```typescript
interface State {
toasts: Toast[];
pausedAt: number | undefined;
}
```
--------------------------------
### Default Toaster Options
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/utility-functions.md
Provides the default configuration for the Toaster component.
```typescript
const defaultToasterOptions: ToasterProps = {
position: 'top-right',
toastOptions: defaultToastOptions,
gutter: 8,
containerStyle: {},
containerClassName: '',
}
```
--------------------------------
### Top-Level API Exports
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/module-structure.md
List of primary exports and types available from the main solid-toast package.
```typescript
// Main API
toast: ToastHandler (with methods: success, error, loading, custom, promise, dismiss, remove)
Toaster: Component
// Types (re-exported from types module)
type Toast
type ToastType
type ToastPosition
type ToastOptions
type ToasterProps
type Renderable
type IconTheme
type Message
type ValueOrFunction
type ValueFunction
type ToastHandler
type ToastContainerProps
type ToastBarProps
type IconProps
type ToastTimeouts
type DefaultToastOptions
type Action
enum ActionType
interface Toast
interface ToasterProps
interface IconTheme
interface ToastContainerProps
interface ToastBarProps
```
--------------------------------
###
Source: https://github.com/ardeora/solid-toast/blob/main/README.md
The component responsible for rendering all toasts.
```APIDOC
##
### Description
This component renders all toasts. It accepts props like position, gutter, containerClassName, containerStyle, and toastOptions for default configurations.
```
--------------------------------
### Batch Multiple Messages
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/quick-start.md
Use a single loading toast and update it upon completion to avoid flooding the UI with multiple notifications.
```typescript
// Instead of creating many toasts
async function saveMultipleFiles(files) {
const id = toast.loading(`Saving ${files.length} files...`);
for (const file of files) {
await saveFile(file);
}
toast.success(`${files.length} files saved`, { id }); // Single final toast
}
```
--------------------------------
### Custom Icons
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/quick-start.md
Add emojis or custom icon themes to notifications.
```typescript
import { toast } from 'solid-toast';
// With emoji
toast('Great job!', { icon: '🎉' });
// With custom colors
toast.success('Done', {
iconTheme: {
primary: '#3b82f6',
secondary: '#dbeafe',
},
});
```
--------------------------------
### Render custom JSX with toast.custom
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/toast-function.md
Use a function to access the toast object and its state for dynamic content rendering.
```typescript
toast.custom((t) => (
Toast ID: {t.id}
{t.visible ? 'Visible' : 'Hiding'}
));
```
--------------------------------
### Dispatch START_PAUSE Action
Source: https://github.com/ardeora/solid-toast/blob/main/_autodocs/api-reference/store.md
Sets pausedAt to the current timestamp and marks all toasts as paused.
```typescript
dispatch({
type: ActionType.START_PAUSE,
time: Date.now(),
});
```