An open API service indexing awesome lists of open source software.

https://github.com/waleedsalah4/notification-system

A customizable toast notification system for React, Angular, and Vue with built-in animations, positioning, auto-dismiss, and more.
https://github.com/waleedsalah4/notification-system

alerts angular context-api custom-toast motion pinia reactjs redux-toolkit toast toast-notifications typescript vue zustand

Last synced: about 2 months ago
JSON representation

A customizable toast notification system for React, Angular, and Vue with built-in animations, positioning, auto-dismiss, and more.

Awesome Lists containing this project

README

          

# πŸ”” Notification Toast

A customizable toast notification system with built-in animations, icons, positioning, delay appearance, and more.

Implemented across **React**, **Angular**, and **Vue 3** β€” each in its own branch, each exploring a different approach to state management.

![notification-toast](https://notification-toast.vercel.app/notification-toast.webp)

---

## πŸš€ Features

- ⚑ Simple one-liner API β€” `addToast()` / service injection / Pinia action
- 🎨 8 built-in variants β€” Primary, Secondary, Success, Error, Warning, Info, Light, Dark
- πŸ“ 6 configurable positions β€” Top/Bottom Β· Left/Right/Center
- πŸ’¨ Auto-dismiss with animated glowing progress bar
- πŸ–± Pause on hover β€” timer freezes on mouse-over
- πŸ•’ Delay appearance β€” show toast after a short delay
- 🧩 Optional title, custom message, and per-variant icons
- πŸ”” `onCloseToast` callback β€” fires on auto or manual dismiss
- ✨ Fluid animations powered by **motion/react** and **motion-v**

---

## πŸ“‚ Branches

| Branch | Framework | State Management |
|---|---|---|
| `main` | React | Redux Toolkit |
| `toast-with-zustand` | React | Zustand |
| `toast-with-context-api` | React | Context API + useReducer |
| `toasts-in-angular` | Angular 17+ | Angular Signals |
| `toasts-in-vue` | Vue 3 | Pinia |

---

## 🧱 Usage

### React (Redux Toolkit)

```tsx
dispatch(addToast({
type: "success",
title: "Done!",
message: "Your changes have been saved.",
delayAppearance: false,
onCloseToast: () => console.log("closed"),
}));
```

### React (Zustand)

```tsx
const { addToast } = useToastStore();

addToast({
type: "info",
message: "Zustand-powered toast!",
});
```

### React (Context API)

```tsx
const { addToast } = useToastContext();

addToast({
type: "warning",
title: "Heads up",
message: "Context API toast, no extra libraries.",
});
```

### Angular

```ts
// inject
private toastService = inject(ToastService);

this.toastService.addToast({
type: "success",
title: "Success",
message: "Angular Signals-powered toast!",
delayAppearance: false,
});
```

### Vue 3 (Pinia)

```ts
const toastStore = useToastStore();

toastStore.addToast({
type: "success",
title: "Saved!",
message: "Vue 3 + Pinia toast.",
});
```

---

## πŸ“‹ Props / API

| Prop | Type | Default | Description |
|---|---|---|---|
| `type` | `ToastVariant` | **required** | Visual variant (success, error, info…) |
| `message` | `string` | **required** | Main notification text |
| `title` | `string` | `β€”` | Optional bold heading above the message |
| `id` | `string` | auto | Unique ID β€” auto-generated if omitted |
| `delayAppearance` | `boolean` | `false` | Show toast after a short delay (~1s) |
| `onCloseToast` | `() => void` | `β€”` | Callback fired when toast is dismissed |

---

## πŸ“¦ Getting Started

Clone the repo and switch to your desired branch:

```bash
git clone https://github.com/waleedsalah4/notification-system.git
cd notification-system
```

### React (main / zustand / context-api)

```bash
git checkout main # or toast-with-zustand / toast-with-context-api
npm install
npm run dev
```

### Angular

```bash
git checkout toasts-in-angular
npm install
ng serve
```

### Vue 3

```bash
git checkout toasts-in-vue
npm install
npm run dev
```

---

## πŸ›  Built With

### React branches

- React 19 Β· TypeScript Β· Vite
- Redux Toolkit / Zustand / Context API
- Tailwind CSS Β· motion/react

### Angular branch

- Angular 17+ Β· TypeScript
- Standalone Components Β· Angular Signals
- Tailwind CSS

### Vue 3 branch

- Vue 3 Β· TypeScript Β· Vite
- Pinia Β· motion-v
- Tailwind CSS