Gathering detailed insights and metrics for @ngxpert/hot-toast
Gathering detailed insights and metrics for @ngxpert/hot-toast
Gathering detailed insights and metrics for @ngxpert/hot-toast
Gathering detailed insights and metrics for @ngxpert/hot-toast
npm install @ngxpert/hot-toast
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
76 Stars
51 Commits
9 Forks
1 Watching
2 Branches
2 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
TypeScript (68.74%)
HTML (16.33%)
SCSS (11.16%)
JavaScript (3.31%)
CSS (0.47%)
Cumulative downloads
Total Downloads
Last day
-27.6%
504
Compared to previous day
Last week
-5.4%
3,156
Compared to previous week
Last month
25.4%
14,504
Compared to previous month
Last year
0%
52,810
Compared to previous year
1
2
Smoking hot Notifications for Angular. Lightweight, customizable and beautiful by default. Inspired from react-hot-toast
https://github.com/ngxpert/hot-toast/assets/6831283/ae718568-d5ea-47bf-a41d-6aabc7d4a044
@ngxpert/hot-toast | Angular |
---|---|
1.x, 2.x | >= 17 < 18 |
3.x | >= 18 |
With npm:
1npm install @ngneat/overview@6.0.0 @ngxpert/hot-toast
or yarn
1yarn add @ngneat/overview@6.0.0 @ngxpert/hot-toast
You can install it through Angular CLI:
1ng add @ngneat/hot-toast
or with npm:
1# For Angular version >= 9.1.13 < 13 2npm install @ngneat/overview@2.0.2 @ngneat/hot-toast@3 3 4# For Angular version >= 13 < 15 5npm install @ngneat/overview@3.0.0 @ngneat/hot-toast@4 6 7# For Angular version >= 15 <16 8npm install @ngneat/overview@3.0.0 @ngneat/hot-toast@5 9 10# For Angular version >= 16 <17 11npm install @ngneat/overview@5.1.1 @ngneat/hot-toast@6
If you use SCSS add this line to your main styles.scss:
1@use 'node_modules/@ngxpert/hot-toast/src/styles/styles.scss';
or if you use CSS add this to your styles inside your angular.json:
1"styles": [ 2 "node_modules/@ngxpert/hot-toast/src/styles/styles.css", 3],
1import { AppComponent } from './src/app.component'; 2 3import { provideHotToastConfig } from '@ngxpert/hot-toast'; 4 5bootstrapApplication(AppComponent, { 6 providers: [ 7 provideHotToastConfig(), // @ngxpert/hot-toast providers 8 ] 9});
Add provideHotToastConfig()
to your app.module.ts providers
section. Toast options (Partial<ToastConfig>
) here.:
1import { providerHotToastConfig } from '@ngxpert/hot-toast'; 2 3@NgModule({ 4 providers: [provideHotToastConfig()], 5}) 6class AppModule {}
if you use SCSS add this line to your main styles.scss:
1@use '@ngxpert/hot-toast/src/styles/styles.scss';
or if you use CSS add this to your styles inside your angular.json:
1"styles": [ 2 "node_modules/@ngxpert/hot-toast/src/styles/styles.css", 3],
1import { HotToastService } from '@ngxpert/hot-toast'; 2 3@Component({}) 4export class AppComponent { 5 constructor(private toast: HotToastService) {} 6 7 showToast() { 8 this.toast.show('Hello World!'); 9 this.toast.loading('Lazyyy...'); 10 this.toast.success('Yeah!!'); 11 this.toast.warning('Boo!'); 12 this.toast.error('Oh no!'); 13 this.toast.info('Something...'); 14 } 15 16 update() { 17 saveSettings 18 .pipe( 19 this.toast.observe({ 20 loading: 'Saving...', 21 success: 'Settings saved!', 22 error: 'Could not save.', 23 }) 24 ) 25 .subscribe(); 26 } 27}
You can pass ToastOptions
while creating the toast to customize the look and behavior:
1import { HotToastService } from '@ngxpert/hot-toast'; 2 3@Component({}) 4export class AppComponent { 5 constructor(private toast: HotToastService) {} 6 7 customToast() { 8 this.toast.success('Look at my styles, and I also need more time!', { 9 duration: 5000, 10 style: { 11 border: '1px solid #713200', 12 padding: '16px', 13 color: '#713200', 14 }, 15 iconTheme: { 16 primary: '#713200', 17 secondary: '#FFFAEE', 18 }, 19 }); 20 } 21}
You can also set global ToastConfig
options while importing:
1import { provideHotToastConfig } from '@ngxpert/hot-toast'; 2 3@NgModule({ 4 providers: [ 5 provideHotToastConfig({ 6 reverseOrder: true, 7 dismissible: true, 8 autoClose: false, 9 }), 10 ], 11}) 12class AppModule {}
Additionally, you have the option of using a standalone function to provide a global toast configuration within your app's configuration file:
1// app.config.ts 2import { provideHotToastConfig } from '@ngxpert/hot-toast'; 3 4export const appConfig: ApplicationConfig = { 5 providers: [provideHotToastConfig({ ... })], 6};
You can checkout examples at: https://ngxpert.github.io/hot-toast#examples.
All options, which are set Available in global config? from ToastOptions
are supported. Below are extra configurable options:
Name | Type | Description |
---|---|---|
reverseOrder | boolean | Sets the reverse order for hot-toast stacking Default: false |
visibleToasts | number | Sets the number of toasts visible. 0 will set no limit. Default: 5 |
stacking | "vertical"|"depth" | Sets Sets the type of stacking Default: "vertical" |
Configuration used when opening an hot-toast.
Name | Type | Description | Available in global config? |
---|---|---|---|
id | string | Unique id to associate with hot-toast. There can't be multiple hot-toasts opened with same id. Example | No |
duration | number | Duration in milliseconds after which hot-toast will be auto closed. Can be disabled via autoClose: false Default: 3000, error = 4000, loading = 30000 | Yes |
autoClose | boolean | Auto close hot-toast after duration Default: true | Yes |
position | ToastPosition | The position to place the hot-toast. Default: top-center Example | Yes |
dismissible | boolean | Show close button in hot-toast Default: false Example | Yes |
role | ToastRole | Role of the live region. Default: status | Yes |
ariaLive | ToastAriaLive | aria-live value for the live region. Default: polite | Yes |
theme | ToastTheme | Visual appearance of hot-toast Default: toast Example | Yes |
persist | {ToastPersistConfig} | Useful when you want to keep a persistance for toast based on ids, across sessions. Example | No |
icon | Content | Icon to show in the hot-toast Example | Yes |
iconTheme | IconTheme | Use this to change icon color Example | Yes |
className | string | Extra CSS classes to be added to the hot toast container. | Yes |
attributes | Record<string, string> | Extra attributes to be added to the hot toast container. Can be used for e2e tests. | Yes |
style | style object | Extra styles to apply for hot-toast. Example | Yes |
closeStyle | style object | Extra styles to apply for close button | Yes |
data | DataType | Allows you to pass data for your template and component. You can access the data using toastRef.data .Examples: Template with Data, Component with Data | No |
injector | Injector | Allows you to pass injector for your component. Example | No |
group | group | Allows you to set group options. Examples: Pre-Grouping, Post-Grouping | No |
Latest versions of Chrome, Edge, Firefox and Safari are supported, with some known issues.
Hot-toast messages are announced via an aria-live
region. By default, the polite
setting is used. While polite
is recommended, this can be customized by setting the ariaLive
property of the ToastConfig
or ToastOptions
.
Focus is not, and should not be, moved to the hot-toast element. Moving the focus would be disruptive to a user in the middle of a workflow. It is recommended that, for any action offered in the hot-toast, the application offers the user an alternative way to perform the action. Alternative interactions are typically keyboard shortcuts or menu options. When the action is performed in this way, the hot-toast should be dismissed.
Hot-toasts that have an action available should be set autoClose: false
, as to accommodate screen-reader users that want to navigate to the hot-toast element to activate the action.
The <div>
surrounding <ng-container>
is removed from .hot-toast-message
to better and easy structure of layout. User may need to check their templates after updating to v2.
None
Thanks goes to these wonderful people (emoji key):
Dharmen Shah 💻 🖋 🎨 📖 💡 | Netanel Basal 🐛 💼 🤔 🚧 🧑🏫 📆 🔬 👀 | Timo Lins 🎨 🤔 | Patrick Miller 🚧 📦 | Gili Yaniv 💻 | Artur Androsovych 🚧 | Luis Castro 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
No vulnerabilities found.
No security vulnerabilities found.