# @kovalenko/snack-bar

> This module provides a service to open Material Snackbar with default dismiss action.

Latest version **1.0.3** (published 2023-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kovalenko/snack-bar
pnpm add @kovalenko/snack-bar
yarn add @kovalenko/snack-bar
bun add @kovalenko/snack-bar
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-03-10 |
| First published | 2023-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 24.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kovalenko |
| Maintainers | kovalenko |
| Keywords | angular, material, snackbar |

## Links

- npm: https://www.npmjs.com/package/@kovalenko/snack-bar
- Repository: https://github.com/menelai/snack-bar
- Homepage: https://github.com/menelai/snack-bar#readme
- Issues: https://github.com/menelai/snack-bar/issues
- npm.io page: https://npm.io/package/@kovalenko/snack-bar

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2023-03-10
- 1.0.2 — 2023-03-10

## README

# Material Snackbar with default action

This module provides a service to open Material Snackbar with default dismiss action.

## Installation

```
npm install @kovalenko/snack-bar
```

## Usage

First, import the SnackBarModule to your module:

```typescript
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {SnackBarModule} from '@kovalenko/snack-bar';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {DialogComponent} from './app';

@NgModule({
  imports: [BrowserModule, SnackBarModule],
  declarations: [DialogComponent],
  bootstrap: [DialogComponent],
})
export class AppModule { }

platformBrowserDynamic().bootstrapModule(DialogComponent);
```

Then inject SnackBarService:
```typescript
import {Component} from '@angular/core';
import {SnackBarService, snack} from 'snack-bar';

@Component({
  template: ``
})
export class DialogComponent {

  constructor(
    private readonly snackBarService: SnackBarService,
  ) { }

  ngOnInit(): void {
    // Set default action title globally
    this.snackBarService.defaultAction = 'Close';
    
    // Launch snackbar
    this.snackBarService.open('Privet', snack.error);
  }
}
```

### API

#### SnackBarService

##### Properties

defaultAction?: string;

##### Methods

<table>
<tr>
<th colspan="2">open</th>
</tr>
<tr>
<td colspan="2">Opens a snackbar with a message and default action</td>
</tr>
<tr>
<th colspan="2">Parameters</th>
</tr>
<tr>
<td>message<br>string</td><td>The message to show in the snackbar</td>
</tr>
<tr>
<td>config?<br>MatSnackBarConfig&lt;any&gt;</td><td>Additional configuration options for the snackbar</td>
</tr>
<tr>
<td>action?<br>string</td><td>The label for the snackbar action</td>
</tr>
<tr>
<th colspan="2">Returns</th>
</tr>
<tr>
<td colspan="2">MatSnackBarRef&lt;any&gt;</td>
</tr>
</table>


## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/@kovalenko/snack-bar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
