9.0.3 • Published 3 months ago

@exmg/exmg-snackbar v9.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

<exmg-snackbar> Published on npm

@exmg/exmg-snackbar

Snackbar element to show information and feedback based on user interaction.

Based on mwc-snackbar

Installation

npm install @exmg/exmg-snackbar

Example Usage

  <exmg-button unelevated @click=${() =>
    this.shadowRoot?.querySelector<ExmgSnackbar>('#default-snackbar')?.show()}>
    Open default
  </exmg-button>
  <exmg-snackbar id="default-snackbar" labelText="Default auto close"></exmg-snackbar>

API

Slots

NameDescription
iconIcon of the snackbar
actionAction element of the snackbar
dismissDismiss element of the snackbar, used to dismiss the snackbar

Properties/Attributes

NameTypeDefaultDescription
variantstringnullSets the Snackbar variant, options from MWC ('positive', 'negative', 'info')
xOffsetNumber0The horizontal offset of the snackbar
yOffsetNumber0The vertical offset of the snackbar
openbooleanWhether the snackbar is currently open.
timeoutMsnumberAutomatic dismiss timeout in milliseconds. Value must be between 4000 and 10000 (or -1 to disable the timeout completely) or an error will be thrown. Defaults to 5000 (5 seconds).
closeOnEscapebooleanWhether the snackbar closes when it is focused and the user presses the ESC key. Defaults to false.
labelTextstringThe text content of the label element.
stackedbooleanEnables the stacked layout (see above).
leadingbooleanEnables the leading layout (see above).

Methods

NameDescription
show() => voidOpens the snackbar.
close(reason: string = '') => voidCloses the snackbar, optionally with the specified reason indicating why it was closed.

Events

NameDetailDescription
MDCSnackbar:opening{}Indicates when the snackbar begins its opening animation.
MDCSnackbar:opened{}Indicates when the snackbar finishes its opening animation.
MDCSnackbar:closing{reason?: string}Indicates when the snackbar begins its closing animation. reason contains the reason why the snackbar closed ('dismiss', 'action', or a custom string via the close method).
MDCSnackbar:closed{reason?: string}Indicates when the snackbar finishes its closing animation. reason contains the reason why the snackbar closed ('dismiss', 'action', or a custom string via the close method).

CSS Custom Properties

NameDefaultDescription
--mdc-snackbar-action-colornpm.io #bb86fcColor of the action button text.

Additional references

9.0.3

3 months ago

9.0.1

3 months ago

8.1.37

8 months ago

8.1.36

10 months ago

8.1.31

12 months ago

8.1.32

12 months ago

8.1.35

11 months ago

8.1.23

2 years ago

8.1.17

2 years ago