# @polymer/paper-toast

> A material design notification toast

Latest version **3.0.1** (published 2018-09-14) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @polymer/paper-toast
pnpm add @polymer/paper-toast
yarn add @polymer/paper-toast
bun add @polymer/paper-toast
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2018-09-14 |
| First published | 2016-02-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 25.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Author | The Polymer Authors |
| Maintainers | aomarks, azakus, bicknellr, emarquez, justinfagnani, keanulee, notwaldorf, polymer-devs, samli, sorvell, usergenic |
| Keywords | web-components, polymer, toast, notification |

## Links

- npm: https://www.npmjs.com/package/@polymer/paper-toast
- Repository: https://github.com/PolymerElements/paper-toast
- Homepage: https://github.com/PolymerElements/paper-toast#readme
- Issues: https://github.com/PolymerElements/paper-toast/issues
- npm.io page: https://npm.io/package/@polymer/paper-toast

## Dependencies (4)

- [@polymer/polymer](https://npm.io/package/@polymer/polymer.md) ^3.0.0
- [@polymer/iron-fit-behavior](https://npm.io/package/@polymer/iron-fit-behavior.md) ^3.0.0-pre.26
- [@polymer/iron-a11y-announcer](https://npm.io/package/@polymer/iron-a11y-announcer.md) ^3.0.0-pre.26
- [@polymer/iron-overlay-behavior](https://npm.io/package/@polymer/iron-overlay-behavior.md) ^3.0.0-pre.27

## 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

- 3.0.1 (latest) — 2018-09-14
- 3.0.0-pre.20 (next) — 2018-06-23
- 1.3.0-pre.3 (preview) — 2017-01-24
- 3.0.0 — 2018-09-13
- 3.0.0-pre.26 — 2018-09-12
- 3.0.0-pre.25 — 2018-08-29
- 3.0.0-pre.24 — 2018-08-29
- 3.0.0-pre.23 — 2018-08-25
- 3.0.0-pre.22 — 2018-08-25
- 3.0.0-pre.21 — 2018-06-23
- 3.0.0-pre.19 — 2018-05-09
- 3.0.0-pre.18 — 2018-05-09
- 3.0.0-pre.17 — 2018-05-08
- 3.0.0-pre.16 — 2018-05-04
- 3.0.0-pre.15 — 2018-05-02
- … 17 more at https://npm.io/package/@polymer/paper-toast/versions

## README

[![Published on NPM](https://img.shields.io/npm/v/@polymer/paper-toast.svg)](https://www.npmjs.com/package/@polymer/paper-toast)
[![Build status](https://travis-ci.org/PolymerElements/paper-toast.svg?branch=master)](https://travis-ci.org/PolymerElements/paper-toast)
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://webcomponents.org/element/@polymer/paper-toast)

## &lt;paper-toast&gt;
`paper-toast` provides a subtle notification toast. Only one `paper-toast` will
be visible on screen.

Use `opened` to show the toast:

Example:

```html
<paper-toast text="Hello world!" opened></paper-toast>
```

Also `open()` or `show()` can be used to show the toast:

Example:

```html
<paper-button on-click="openToast">Open Toast</paper-button>
<paper-toast id="toast" text="Hello world!"></paper-toast>

...

openToast: function() {
  this.$.toast.open();
}
```

Set `duration` to 0, a negative number or Infinity to persist the toast on screen:

Example:

```html
<paper-toast text="Terms and conditions" opened duration="0">
  <a href="#">Show more</a>
</paper-toast>
```

`<paper-toast>` is affected by the [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context) of its container. Adding `<paper-toast>` inside elements that create a new stacking context - e.g. `<app-drawer>`, `<app-layout>` or `<iron-list>` - might result in toasts partially obstructed or clipped. Add `<paper-toast>` to the top level (`<body>`) element, outside the structure, e.g.:

```html
  <!-- ... -->
  </app-drawer-layout>
  <paper-toast id="toast"></paper-toast>
</template>
```

You can then use custom events to communicate with it from within child components, using `addEventListener` and `dispatchEvent`.

### Styling

The following custom properties and mixins are available for styling:

| Custom property | Description | Default |
| --- | --- | --- |
| `--paper-toast-background-color` | The paper-toast background-color | `#323232` |
| `--paper-toast-color` | The paper-toast color | `#f1f1f1` |

This element applies the mixin `--paper-font-common-base` but does not import `paper-styles/typography.html`.
In order to apply the `Roboto` font to this element, make sure you've imported `paper-styles/typography.html`.

See: [Documentation](https://www.webcomponents.org/element/@polymer/paper-toast),
  [Demo](https://www.webcomponents.org/element/@polymer/paper-toast/demo/demo/index.html).

## Usage

### Installation
```
npm install --save @polymer/paper-toast
```

### In an html file
```html
<html>
  <head>
    <script type="module">
      import '@polymer/paper-toast/paper-toast.js';
    </script>
  </head>
  <body>
    <paper-toast text="Hello world!" opened></paper-toast>
  </body>
</html>
```
### In a Polymer 3 element
```js
import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/paper-toast/paper-toast.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <paper-toast text="Hello world!" opened></paper-toast>
    `;
  }
}
customElements.define('sample-element', SampleElement);
```

## Contributing
If you want to send a PR to this element, here are
the instructions for running the tests and demo locally:

### Installation
```sh
git clone https://github.com/PolymerElements/paper-toast
cd paper-toast
npm install
npm install -g polymer-cli
```

### Running the demo locally
```sh
polymer serve --npm
open http://127.0.0.1:<port>/demo/
```

### Running the tests
```sh
polymer test --npm
```

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