BrowseToast

Feedback

Glass Toast

A short-lived glass note that slides in, announces itself and swipes away.

Preview

Glass toast
It stays until you dismiss it.

Installation

Install the package once, then import the parts you use into a standalone component.

Install

npm install ngx-vitreo @angular/cdk @floating-ui/dom
Import

import { GlassToastProvider, GlassToast, GlassToastTitle / GlassToastDescription, GlassToastAction, GlassToastClose, GlassToastViewport } from 'ngx-vitreo';

@Component({
  imports: [GlassToastProvider, GlassToast, GlassToastTitle / GlassToastDescription, GlassToastAction, GlassToastClose, GlassToastViewport],
  // ...
})

Usage

Usage

<glass-toast-provider>
  <glass-toast [(open)]="saved">
    <div glassToastTitle>Saved</div>
    <div glassToastDescription>Your changes are stored.</div>
    <button glassToastClose></button>
  </glass-toast>
  <glass-toast [(open)]="deleted">
    <div glassToastTitle>Message deleted</div>
    <button glassToastAction altText="Undo the delete" (click)="undo()">Undo</button>
  </glass-toast>
  <glass-toast-viewport />
</glass-toast-provider>

API reference

GlassToastProvider

<glass-toast-provider>

InputTypeDefaultDescription
durationnumber5000Milliseconds before a toast closes on its own.
swipeDirection'right' | 'left' | 'up' | 'down''right'The way a swipe dismisses a toast; toasts also slide in from and out to this side.
labelstring'Notification'Prefix screen readers announce before each toast.

GlassToast

<glass-toast>

InputTypeDefaultDescription
open / defaultOpenboolean (model)trueControlled with [(open)], or uncontrolled; an uncontrolled toast shows as it renders.
durationnumber provider duration Overrides the provider's duration for this toast.
classstringNoneApplies to the outer list item, not the glass card inside it.

GlassToastTitle / GlassToastDescription

[glassToastTitle], [glassToastDescription]

InputTypeDefaultDescription
——NoneThe heading and the message text. Also <glass-toast-title> and <glass-toast-description>.

GlassToastAction

button[glassToastAction]

InputTypeDefaultDescription
altTextstringNoneRequired. Tells screen reader users how to do the action without the button.

GlassToastClose

button[glassToastClose]

InputTypeDefaultDescription
aria-labelstring 'Dismiss' without content Draws its own × unless given content; its text names it otherwise.

GlassToastViewport

<glass-toast-viewport>

InputTypeDefaultDescription
hotkeystring[]['F8']Keys that move focus to the toasts.
labelstring'Notifications ({hotkey})'Accessible name of the region.