π Announcing Angular Hot Toast β The Best Angular Toast in Town
--
A few weeks ago Netanel Basal came up with an idea to create react-hot-toast like library for Angular community.
And I am really glad that we ended up creating the best Angular toast in town, announcingβ¦
π Angular Hot Toast β The Best Angular Toast in Town
Getting Started
You can install it through Angular CLI:
npm install @ngneat/overview @ngneat/hot-toast
When you install using npm or yarn, you will also need to import HotToastModule
in your app.module
. You can also set global toast options () here.:
typescript
import { HotToastModule } from β@ngneat/hot-toastβ;@NgModule({
imports: [HotToastModule.forRoot()],
})
class AppModule {}
Features
- π₯ Hot by default
- β Easy to use
- π Snackbar variation
- βΏ Accessible
- ποΈ Reduce motion support
- π Emoji Support
- π Customizable
- β³ Observable API
- β Pause on hover
- π Events
- π Persistent
Here are some basic examples:
import { HotToastService } from '@ngneat/hot-toast';
@Component({})
export class AppComponent {
constructor(private toast: HotToastService) {}
showToast() {
this.toast.show('π Hello World!');
this.toast.success('π Yeah!!');
this.toast.warning('π§ Boo!');
this.toast.error('π Oh no!');
}
}
A common task is to show a success or error toasts based on the server response. To make your life easier, we created a custom operator that will do the work for you:
import { HotToastService } from '@ngneat/hot-toast';
@Component({})
export class AppComponent {
constructor(private toast: HotToastService,
private usersService: UsersService) {}
update() {
this.usersService.updateUser().pipe(
this.toast.observe({
loading: 'Updating...',
success: 'π',
error: 'π‘'
})
).subcribe()
}
}
Checkout more examples at: https://ngneat.github.io/hot-toast/
Repo
Do checkout the library and let us know your feedback. You can reach-out to me at @shhdharmen.
Happy Coding
π² π π
Originally published at https://blog.shhdharmen.me on February 2, 2021.