1.1.3 • Published 19 days ago

@synerise/ds-toast v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
19 days ago

id: toast

title: Toast

Toast UI Component

Installation

npm i @synerise/ds-toast
or
yarn add @synerise/ds-toast

Usage

import Toast from '@synerise/ds-toast';
import Button from '@synerise/ds-button';

<Button onClick={() => Toast.success({message: 'Message title'})} />

Demo

API

PropertyDescriptionTypeDefault
typemessage type'success' / 'negative' / 'warning' / 'informative'-
messagemessage main contentReactNode-
descriptionmessage descriptionReactNode-
customIconoverwrite default icon (default icon depends on type)ReactNode-
expanderrender with expander iconboolean-
onExpandtriggered on click of expander icon(expanded: boolean) => void-
expandedContentcontent rendered if exapanded prop is trueReactNode-
expandedtoggles rendering expanded contentboolean-
withCloserenders X icon to manually dismiss toastboolean-
onCloseClicktriggered on click of close icon() => void-
buttonbutton element to render below message contentReactNode-

Static methods

To display a Toast using Toaster (it is rendered inside DSProvider by default) use any of the shortcut methods provided:

  • Toast.success(props) - shows a Toast type 'success'
  • Toast.error(props) - shows a Toast type 'negative'
  • Toast.info(props) - shows a Toast type 'informative'
  • Toast.warning(props) - shows a Toast type 'warning'
import Toast from '@synerise/ds-toast';
import Button from '@synerise/ds-button';

<Button onClick={() => Toast.success({message: 'Message title'})} />

Additional methods

removeToast(toastId?)

Removes a specific or all displayed toasts instantly

dismissToast(toastId?)

Removes a specific or all displayed toasts with an exit animation.

showToast(type, toastProps, toastOptions?)

enders a Toast of specified type, using toastProps and then displays it using the Toaster with toastOptoins. returns a toastID that can be later used to remove / dismiss that toast manually.

1.1.3

19 days ago

1.1.2

29 days ago

1.1.1

1 month ago

1.1.0

2 months ago