DocSpace-client/packages/shared/components/toast
2024-04-23 12:51:03 +03:00
..
sub-components Merge branch 'develop' into feature/login-nextjs 2024-04-11 11:27:37 +03:00
index.tsx Replaced copyright start year + format 2024-03-21 18:09:55 +04:00
README.md Shared:Components:Toast: rewrite to typescript 2023-12-06 12:53:23 +03:00
Toast.enums.ts Replaced copyright start year + format 2024-03-21 18:09:55 +04:00
toast.stories.tsx Replaced copyright start year + format 2024-03-21 18:09:55 +04:00
Toast.styled.ts Merge branch 'develop' into feature/login-nextjs 2024-04-23 12:51:03 +03:00
toast.test.tsx Shared: fix ts problems 2024-03-22 10:20:39 +03:00
Toast.tsx Shared: fix nextjs probles, add 'use client' and delete useless wrappers and providers 2024-04-04 08:05:50 +03:00
Toast.type.ts Replaced copyright start year + format 2024-03-21 18:09:55 +04: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, toastr } from "@docspace/shared/components";
<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