DocSpace-client/packages/components/toast
2023-05-30 17:08:31 +05:00
..
index.js Web: Components: Toast - removed redundant properties 2023-04-21 17:19:23 +05:00
README.md Web: Moved all clients app to packages directory 2022-07-22 22:01:25 +03:00
styled-toast.js Web:components:Toast Fixed bug 60587 2023-01-19 22:18:39 +05:00
styled-toastr.js Web: Moved all clients app to packages directory 2022-07-22 22:01:25 +03:00
toast.mdx Web: Components: enable mdx format for storybook, rename mdx files 2023-05-29 19:46:28 +05:00
toast.stories.js Web: Components: Tag: added description 2023-05-30 17:08:31 +05:00
toast.test.js Web: Moved all clients app to packages directory 2022-07-22 22:01:25 +03:00
toastr.js Web: Components: Toast: Fixed error toast with custom body 2023-02-06 16:35:50 +03: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 "@docspace/components/toast";
import toastr from "@docspace/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