diff --git a/apps/web-twig-demo/yarn.lock b/apps/web-twig-demo/yarn.lock
index b5e1f628ff..f3bb1f27c7 100644
--- a/apps/web-twig-demo/yarn.lock
+++ b/apps/web-twig-demo/yarn.lock
@@ -2268,10 +2268,10 @@ core-js-compat@^3.36.1:
dependencies:
browserslist "^4.23.0"
-core-js@3.36.1:
- version "3.36.1"
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.36.1.tgz#c97a7160ebd00b2de19e62f4bbd3406ab720e578"
- integrity sha512-BTvUrwxVBezj5SZ3f10ImnX2oRByMxql3EimVqMysepbC9EeMUOpLwdy6Eoili2x6E4kf+ZUB5k/+Jv55alPfA==
+core-js@3.37.0:
+ version "3.37.0"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.37.0.tgz#d8dde58e91d156b2547c19d8a4efd5c7f6c426bb"
+ integrity sha512-fu5vHevQ8ZG4og+LXug8ulUtVxjOcEYvifJr7L5Bfq9GOztVqsKd9/59hUk2ZSbCrS3BqUr3EpaYGIYzq7g3Ug==
core-util-is@~1.0.0:
version "1.0.3"
diff --git a/packages/web-react/src/components/Toast/README.md b/packages/web-react/src/components/Toast/README.md
index 9717df62d8..b594070de0 100644
--- a/packages/web-react/src/components/Toast/README.md
+++ b/packages/web-react/src/components/Toast/README.md
@@ -102,25 +102,41 @@ sorted from top to bottom for the `top` vertical alignment, and from bottom to t
👉 Please note the _actual_ order in the DOM is followed when users tab over the interface, no matter the _visual_
order of the toast queue.
-#### Toast Queue Limitations
+#### Collapsing
+
+The collapsible Toast queue is turned on by default and can hold up to 3 ToastBar components.
+When the queue is full, the oldest ToastBar components are collapsed at the start of
+the queue and are only accessible by closing the newer ones.
-While the Toast queue becomes scrollable when it does not fit the screen, we recommend displaying only a few toasts at
-once for several reasons:
+#### Scrolling
-⚠️ **We strongly discourage from displaying too many toasts at once as it may cause the page to be unusable,
-especially on mobile screens. As of now, there is no automatic stacking of the toast queue items. It is the
-responsibility of the developer to ensure that the Toast queue does not overflow the screen.**
+By default, the Toast queue collapses when there are more than 3 ToastBars. To turn off this behavior and make the queue scrollable when it does not fit the screen,
+set the `isCollapsible` prop to `false`.
⚠️ Please note that scrolling is not available on iOS devices due to a limitation in the WebKit engine.
👉 Please note that the initial scroll position is always at the **top** of the queue.
+```jsx
+
+
+
+```
+
+#### Toast Queue Limitations
+
+👉 Please note only the _visible_ ToastBar components are scrollable. Collapsed items are not accessible until visible
+items are dismissed.
+
+👉 For the sake of simplicity, the collapsible items limit cannot be configured at the moment.
+
### API
-| Name | Type | Default | Required | Description |
-| ------------ | ----------------------------------------------------------- | -------- | -------- | --------------------------------------- |
-| `alignmentX` | [[AlignmentX dictionary][dictionary-alignment] \| `object`] | `center` | ✕ | Horizontal alignment of the toast queue |
-| `alignmentY` | [`top` \| `bottom` \| `object`] | `bottom` | ✕ | Vertical alignment of the toast queue |
+| Name | Type | Default | Required | Description |
+| --------------- | ----------------------------------------------------------- | -------- | -------- | ----------------------------------------------------------------- |
+| `alignmentX` | [[AlignmentX dictionary][dictionary-alignment] \| `object`] | `center` | ✕ | Horizontal alignment of the toast queue |
+| `alignmentY` | [`top` \| `bottom` \| `object`] | `bottom` | ✕ | Vertical alignment of the toast queue |
+| `isCollapsible` | `bool` | `true` | ✕ | If true, Toast queue collapses if there are more than 3 ToastBars |
On top of the API options, the components accept [additional attributes][readme-additional-attributes].
If you need more control over the styling of a component, you can use [style props][readme-style-props]
@@ -315,20 +331,23 @@ This hook returns:
| Name | Type | Default | Description |
| ---------- | ------------------------------------------------------------ | ---------- | --------------------------------------------------- |
+| `clear` | `() => void` | () => {} | Function that will clear toast queue |
| `color` | [[Emotion Color dictionary][dictionary-color] \| `inverted`] | `inverted` | Color variant |
-| `hide` | `function` | () => {} | Function that will hide UncontrolledToast |
+| `hide` | `(toastId) => void` | () => {} | Function that will hide UncontrolledToast |
| `iconName` | `string` | — | Name of a custom icon to be shown along the message |
| `id` | `string` | `''` | ToastBar ID |
| `isOpen` | `bool` | `false` | Open state of UncontrolledToast |
| `message` | [`string` \| `ReactNode`] | null | Message inside UncontrolledToast |
-| `show` | `function` | () => {} | Function that will show UncontrolledToast |
+| `show` | `(message, toastId, options?) => void` | () => {} | Function that will show UncontrolledToast |
-#### How to use `showToast` function:
+#### How to use `show` function:
This function has two required parameters: message and ID.
All other options are not required and can be omitted entirely.
```jsx
+const { show } = useToast();
+
┌─⫸ Message inside UncontrolledToast (required)
│
│ ┌─⫸ ToastBar ID (required)
@@ -336,7 +355,7 @@ All other options are not required and can be omitted entirely.
show('Toast message', 'toast-id', {
color: 'danger', // Color variant, default: 'inverted'
iconName: 'download', // Name of a custom icon to be shown along the message, default: undefined
-})
+});
```
### API
diff --git a/packages/web-react/src/components/Toast/Toast.tsx b/packages/web-react/src/components/Toast/Toast.tsx
index 9a5b22a71a..2dceb602dd 100644
--- a/packages/web-react/src/components/Toast/Toast.tsx
+++ b/packages/web-react/src/components/Toast/Toast.tsx
@@ -2,10 +2,18 @@ import classNames from 'classnames';
import React from 'react';
import { useStyleProps } from '../../hooks';
import { SpiritToastProps } from '../../types';
+import { AlignmentX, AlignmentY } from '../../constants';
import { useToastStyleProps } from './useToastStyleProps';
+const defaultProps: SpiritToastProps = {
+ alignmentX: AlignmentX.CENTER,
+ alignmentY: AlignmentY.BOTTOM,
+ isCollapsible: true,
+};
+
const Toast = (props: SpiritToastProps) => {
- const { children, alignmentX = 'center', alignmentY = 'bottom', ...restProps } = props;
+ const propsWithDefaults = { ...defaultProps, ...props };
+ const { children, alignmentX, alignmentY, ...restProps } = propsWithDefaults;
const { classProps, props: modifiedProps } = useToastStyleProps({ ...restProps, alignmentX, alignmentY });
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);
diff --git a/packages/web-react/src/components/Toast/ToastBar.tsx b/packages/web-react/src/components/Toast/ToastBar.tsx
index 43b8e3dc94..0a25b9b635 100644
--- a/packages/web-react/src/components/Toast/ToastBar.tsx
+++ b/packages/web-react/src/components/Toast/ToastBar.tsx
@@ -47,19 +47,21 @@ const ToastBar = (props: SpiritToastBarProps) => {
className={classNames(classProps.root, TRANSITIONING_STYLES[transitionState], styleProps.className)}
ref={rootElementRef}
>
-