DocSpace-client/packages/asc-web-components/toast
2022-05-16 13:50:07 +03:00
..
svg Web:Components:Toast: update SVG 1.2.1 2021-12-10 19:44:29 +08:00
index.js Web:Editor: add support dark-theme 2022-01-24 22:32:05 +08:00
README.md Web: Components/Common: fix imports 2021-02-26 00:19:45 +03:00
styled-toast.js Web: fixed toasts 2022-05-16 13:50:07 +03:00
styled-toastr.js Web:Components:Toast: add support dark-theme 2021-12-10 20:10:55 +08:00
toast.stories.js changed size names in app buttons 2022-03-10 15:59:04 +03:00
toast.stories.mdx Web: Components: added story for Toast 2021-03-11 19:03:17 +03:00
toast.test.js Web: Components: changed component hierarchy 2021-02-24 17:42:09 +03:00
toastr.js Web:Editor: wrap editor in theme provider and delete theme as props in components 2022-01-27 21:54:58 +08:00

Toast

Toast allow you to add notification to your page with ease.

<Toast /> is container for your notification. Remember to render the <Toast /> once in your application tree. If you can't figure out where to put it, rendering it in the application root would be the best bet.

toastr is a function for showing notifications.

Usage

import Toast from "@appserver/components/toast";
import toastr from "@appserver/components/toast/toastr";
<Toast />
<button onClick={() => toastr.success('Some text for toast', 'Some text for title', true)}>Click</button>

or

<Toast>{toastr.success("Some text for toast")}</Toast>

You can use simple html tags. For this action you should wrap your message by empty tags:

<Toast />
<button onClick={() => toastr.success(<>You have <b>bold text</b></>)}>Click</button>

If your notification include only text in html tags or data in JSX tags, you can omit empty tags:

<Toast />
<button onClick={() => toastr.success(<b>Bold text</b>)}>Click</button>

Other Options

<Toast/>
    // Remove all toasts in your page programmatically
<button onClick = {()=> { toastr.clear() }}>Clear</button>

Properties

Props Type Required Values Default Description
className string - - - Accepts class
data element,string - - - Any components or data inside a toast
id string - - - Accepts id
style obj, array - - - Accepts css style
timeout number - from 750ms, 0 - disabling 5000 Time (in milliseconds) for showing your toast. Setting in 0 let you to show toast constantly until clicking on it
title string - - - Title inside a toast
type oneOf success, error, warning, info - Define color and icon of toast
withCross bool - - false If false: toast disappeared after clicking on any area of toast. If true: toast disappeared after clicking on close button