A lightweight, customizable toast notification library for web applications
Ark JS Alert is a simple yet powerful JavaScript library for displaying toast notifications in web applications. It's lightweight, customizable, and easy to integrate into any project.
This documentation provides detailed information about all available functions, their parameters, and usage examples.
To get started with Ark JS Alert, include the library in your HTML file:
Then call any of the available functions:
Displays a success notification with a green color scheme.
| Parameter | Type | Default | Description |
|---|---|---|---|
| message | String | Required | The text content to display in the toast |
| duration | Number | 3000 | Duration in milliseconds before the toast automatically closes |
| options | Object | {} | Additional configuration options (see below) |
Displays an error notification with a red color scheme.
| Parameter | Type | Default | Description |
|---|---|---|---|
| message | String | Required | The text content to display in the toast |
| duration | Number | 5000 | Duration in milliseconds before the toast automatically closes |
| options | Object | {} | Additional configuration options (see below) |
Displays a warning notification with an orange color scheme.
| Parameter | Type | Default | Description |
|---|---|---|---|
| message | String | Required | The text content to display in the toast |
| duration | Number | 4000 | Duration in milliseconds before the toast automatically closes |
| options | Object | {} | Additional configuration options (see below) |
Displays an informational notification with a blue color scheme.
| Parameter | Type | Default | Description |
|---|---|---|---|
| message | String | Required | The text content to display in the toast |
| duration | Number | 4000 | Duration in milliseconds before the toast automatically closes |
| options | Object | {} | Additional configuration options (see below) |
Displays a custom notification with specified type and styling.
| Parameter | Type | Default | Description |
|---|---|---|---|
| message | String | Required | The text content to display in the toast |
| type | String | 'info' | The type of notification (success, error, warning, info, or custom) |
| duration | Number | 4000 | Duration in milliseconds before the toast automatically closes |
| options | Object | {} | Additional configuration options (see below) |
The options parameter allows you to customize the appearance and behavior of the notifications.
| Option | Type | Default | Description |
|---|---|---|---|
| position | String | 'top-right' | Position of the toast. Options: 'top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left', 'bottom-center' |
| backgroundColor | String | Type-dependent | Custom background color for the toast |
| textColor | String | '#fff' | Custom text color for the toast |
| closeButton | Boolean | true | Whether to show a close button |
| progressBar | Boolean | true | Whether to show a progress bar indicating remaining time |
| animation | String | 'fade' | Animation type. Options: 'fade', 'slide', 'zoom' |
You can set global defaults for all notifications using the setDefaults method.
For more advanced use cases, you can chain multiple notifications or use callbacks.