Skip to content

The open alternative to Salesforce, designed for AI.

Extract frontend snack bar into twenty-ui Toast (#25663)

Raphaël Bosi2d4c14f353ae
diff --git a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/components/SnackBar.tsx b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/components/SnackBar.tsx
index 5738edae666..43391b1753b 100644
--- a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/components/SnackBar.tsx
+++ b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/components/SnackBar.tsx
@@ -1,31 +1,11 @@
import { sanitizeMessageToRenderInSnackbar } from '@/ui/feedback/snack-bar-manager/utils/sanitizeMessageToRenderInSnackbar';
-import { styled } from '@linaria/react';
import { msg } from '@lingui/core/macro';
import { useLingui } from '@lingui/react/macro';
-import { isUndefined } from '@sniptt/guards';
-import {
- type ComponentPropsWithoutRef,
- type ReactNode,
- useContext,
- useMemo,
- useState,
-} from 'react';
+import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
import { isDefined } from 'twenty-shared/utils';
-import {
- IconAlertTriangle,
- IconInfoCircle,
- IconSquareRoundedCheck,
- IconX,
-} from 'twenty-ui/icon';
-import { HorizontalSeparator } from 'twenty-ui/layout';
-import { ProgressBar } from 'twenty-ui/feedback';
-import { LightButton, LightIconButton } from 'twenty-ui/input';
+import { Toast } from 'twenty-ui/feedback';
+import { LightButton } from 'twenty-ui/input';
import { UndecoratedLink } from 'twenty-ui/navigation';
-import {
- MOBILE_VIEWPORT,
- ThemeContext,
- themeCssVariables,
-} from 'twenty-ui/theme-constants';
export enum SnackBarVariant {
Default = 'default',
@@ -52,83 +32,7 @@ export type SnackBarProps = Pick<ComponentPropsWithoutRef<'div'>, 'id'> & {
dedupeKey?: string;
};
-const StyledContainer = styled.div`
- backdrop-filter: ${themeCssVariables.blur.medium};
- background-color: ${themeCssVariables.background.transparent.primary};
- border-radius: ${themeCssVariables.border.radius.md};
- box-shadow: ${themeCssVariables.boxShadow.strong};
- box-sizing: border-box;
- margin-top: ${themeCssVariables.spacing[2]};
- padding: ${themeCssVariables.spacing[2]} ${themeCssVariables.spacing[2]}
- ${themeCssVariables.spacing[1]};
- position: relative;
- width: 296px;
-
- @media (max-width: ${MOBILE_VIEWPORT}px) {
- border-radius: 0;
- width: 100%;
- }
-`;
-
-const StyledProgressBarContainer = styled.div`
- bottom: 0;
- left: 0;
- pointer-events: none;
- position: absolute;
- right: 0;
- top: 0;
-
- & > [role='progressbar'] {
- height: 100%;
- }
-`;
-
-const StyledHeader = styled.div`
- align-items: center;
- color: ${themeCssVariables.font.color.primary};
- display: flex;
- font-weight: ${themeCssVariables.font.weight.medium};
- gap: ${themeCssVariables.spacing[2]};
- margin-bottom: ${themeCssVariables.spacing[1]};
-`;
-
-const StyledMessage = styled.div`
- color: ${themeCssVariables.font.color.secondary};
- font-size: ${themeCssVariables.font.size.sm};
-`;
-
-const StyledIcon = styled.div`
- align-items: center;
- display: flex;
-`;
-
-const StyledActions = styled.div`
- align-items: center;
- display: flex;
- margin-left: auto;
-`;
-
-const StyledDescription = styled.div`
- color: ${themeCssVariables.font.color.tertiary};
- font-size: ${themeCssVariables.font.size.sm};
- overflow: hidden;
- padding-left: ${themeCssVariables.spacing[6]};
- text-overflow: ellipsis;
- width: 200px;
-`;
-
-const StyledBottomActionContainer = styled.div`
- margin-top: ${themeCssVariables.spacing[2]};
-`;
-
-const StyledBottomAction = styled.div`
- align-items: center;
- display: flex;
- justify-content: flex-end;
- padding-top: ${themeCssVariables.spacing[1]};
-`;
-
-const defaultAriaLabelByVariant: Record<
+const DEFAULT_ARIA_LABEL_BY_VARIANT: Record<
SnackBarVariant,
ReturnType<typeof msg>
> = {
@@ -141,9 +45,9 @@ const defaultAriaLabelByVariant: Record<
export const SnackBar = ({
className,
- progress: overrideProgressValue,
- duration = 6000,
- icon: iconComponent,
+ progress,
+ duration,
+ icon,
id,
message,
detailedMessage,
@@ -152,108 +56,45 @@ export const SnackBar = ({
buttonTo,
onCancel,
onClose,
- role = 'status',
+ role,
variant = SnackBarVariant.Default,
}: SnackBarProps) => {
const { i18n, t } = useLingui();
- const { theme } = useContext(ThemeContext);
- const [isPaused, setIsPaused] = useState(false);
- const isAutoDismiss = isUndefined(overrideProgressValue);
-
- const icon = useMemo(() => {
- if (isDefined(iconComponent)) {
- return iconComponent;
- }
-
- const ariaLabel = i18n._(defaultAriaLabelByVariant[variant]);
- const color = theme.snackBar[variant].color;
- const size = theme.icon.size.md;
-
- switch (variant) {
- case SnackBarVariant.Error:
- return (
- <IconAlertTriangle {...{ 'aria-label': ariaLabel, color, size }} />
- );
- case SnackBarVariant.Info:
- return <IconInfoCircle {...{ 'aria-label': ariaLabel, color, size }} />;
- case SnackBarVariant.Success:
- return (
- <IconSquareRoundedCheck
- {...{ 'aria-label': ariaLabel, color, size }}
- />
- );
- case SnackBarVariant.Warning:
- return (
- <IconAlertTriangle {...{ 'aria-label': ariaLabel, color, size }} />
- );
- default:
- return (
- <IconAlertTriangle {...{ 'aria-label': ariaLabel, color, size }} />
- );
- }
- }, [iconComponent, variant, i18n, theme.icon.size.md, theme.snackBar]);
-
- const handleMouseEnter = () => {
- setIsPaused(true);
- };
-
- const handleMouseLeave = () => {
- setIsPaused(false);
- };
-
+ const iconLabel = i18n._(DEFAULT_ARIA_LABEL_BY_VARIANT[variant]);
const sanitizedMessage = sanitizeMessageToRenderInSnackbar(message);
const sanitizedDetailedMessage =
sanitizeMessageToRenderInSnackbar(detailedMessage);
+ const hasAction =
+ isDefined(buttonLabel) && (isDefined(buttonOnClick) || isDefined(buttonTo));
+ const action = isDefined(buttonTo) ? (
+ <UndecoratedLink to={buttonTo}>
+ <LightButton title={buttonLabel} />
+ </UndecoratedLink>
+ ) : (
+ <LightButton title={buttonLabel} onClick={buttonOnClick} />
+ );
+
return (
- <StyledContainer
- aria-live={role === 'alert' ? 'assertive' : 'polite'}
- onMouseEnter={handleMouseEnter}
- onMouseLeave={handleMouseLeave}
- title={sanitizedMessage ?? i18n._(defaultAriaLabelByVariant[variant])}
+ <Toast
className={className}
+ progress={progress}
+ duration={duration}
+ icon={icon}
+ iconLabel={iconLabel}
id={id}
+ onCancel={onCancel}
+ onClose={onClose}
role={role}
+ variant={variant}
+ title={sanitizedMessage ?? iconLabel}
+ description={sanitizedDetailedMessage}
+ cancelLabel={t`Cancel`}
+ closeLabel={t`Close`}
+ action={hasAction ? action : undefined}
data-globally-prevent-click-outside
>
- <StyledProgressBarContainer>
- <ProgressBar
- barColor={theme.snackBar[variant].backgroundColor}
- value={overrideProgressValue ?? 100}
- countdownDurationInMs={isAutoDismiss ? duration : undefined}
- isCountdownPaused={isPaused}
- onCountdownComplete={onClose}
- />
- </StyledProgressBarContainer>
- <StyledHeader>
- <StyledIcon>{icon}</StyledIcon>
- <StyledMessage>{sanitizedMessage ?? ''}</StyledMessage>
- <StyledActions>
- {!!onCancel && <LightButton title={t`Cancel`} onClick={onCancel} />}
-
- {!!onClose && (
- <LightIconButton title={t`Close`} Icon={IconX} onClick={onClose} />
- )}
- </StyledActions>
- </StyledHeader>
- {isDefined(sanitizedDetailedMessage) && (
- <StyledDescription>{sanitizedDetailedMessage}</StyledDescription>
- )}
- {isDefined(buttonLabel) &&
- (isDefined(buttonOnClick) || isDefined(buttonTo)) && (
- <StyledBottomActionContainer>
- <HorizontalSeparator noMargin />
- <StyledBottomAction>
- {isDefined(buttonTo) ? (
- <UndecoratedLink to={buttonTo}>
- <LightButton title={buttonLabel} />
- </UndecoratedLink>
- ) : (
- <LightButton title={buttonLabel} onClick={buttonOnClick} />
- )}
- </StyledBottomAction>
- </StyledBottomActionContainer>
- )}
- </StyledContainer>
+ {sanitizedMessage ?? ''}
+ </Toast>
);
};
diff --git a/packages/twenty-ui/src/feedback/Toast/Toast.module.scss b/packages/twenty-ui/src/feedback/Toast/Toast.module.scss
new file mode 100644
index 00000000000..00d88e3a2d8
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/Toast.module.scss
@@ -0,0 +1,71 @@
+.root {
+ backdrop-filter: var(--t-blur-medium);
+ background-color: var(--t-background-transparent-primary);
+ border-radius: var(--t-border-radius-md);
+ box-shadow: var(--t-box-shadow-strong);
+ box-sizing: border-box;
+ inline-size: 296px;
+ margin-block-start: var(--t-spacing-2);
+ padding: var(--t-spacing-2) var(--t-spacing-2) var(--t-spacing-1);
+ position: relative;
+
+ @include respond-to(mobile) {
+ border-radius: 0;
+ inline-size: 100%;
+ }
+}
+
+.progress {
+ inset: 0;
+ pointer-events: none;
+ position: absolute;
+
+ & > [role='progressbar'] {
+ height: 100%;
+ }
+}
+
+.header {
+ align-items: center;
+ color: var(--t-font-color-primary);
+ display: flex;
+ font-weight: var(--t-font-weight-medium);
+ gap: var(--t-spacing-2);
+ margin-block-end: var(--t-spacing-1);
+}
+
+.message {
+ color: var(--t-font-color-secondary);
+ font-size: var(--t-font-size-sm);
+}
+
+.icon {
+ align-items: center;
+ display: flex;
+}
+
+.actions {
+ align-items: center;
+ display: flex;
+ margin-inline-start: auto;
+}
+
+.description {
+ color: var(--t-font-color-tertiary);
+ font-size: var(--t-font-size-sm);
+ inline-size: 200px;
+ overflow: hidden;
+ padding-inline-start: var(--t-spacing-6);
+ text-overflow: ellipsis;
+}
+
+.footer {
+ margin-block-start: var(--t-spacing-2);
+}
+
+.footerAction {
+ align-items: center;
+ display: flex;
+ justify-content: flex-end;
+ padding-block-start: var(--t-spacing-1);
+}
diff --git a/packages/twenty-ui/src/feedback/Toast/Toast.module.scss.d.ts b/packages/twenty-ui/src/feedback/Toast/Toast.module.scss.d.ts
new file mode 100644
index 00000000000..c601510b108
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/Toast.module.scss.d.ts
@@ -0,0 +1,12 @@
+declare const classNames: {
+ readonly root: 'root';
+ readonly progress: 'progress';
+ readonly header: 'header';
+ readonly message: 'message';
+ readonly icon: 'icon';
+ readonly actions: 'actions';
+ readonly description: 'description';
+ readonly footer: 'footer';
+ readonly footerAction: 'footerAction';
+};
+export default classNames;
diff --git a/packages/twenty-ui/src/feedback/Toast/Toast.tsx b/packages/twenty-ui/src/feedback/Toast/Toast.tsx
new file mode 100644
index 00000000000..97489113ee9
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/Toast.tsx
@@ -0,0 +1,121 @@
+import { useRender } from '@base-ui/react/use-render';
+import { clsx } from 'clsx';
+import { type MouseEvent, useState } from 'react';
+
+import { ProgressBar } from '@ui/feedback/ProgressBar/ProgressBar';
+import {
+ IconAlertTriangle,
+ IconInfoCircle,
+ IconSquareRoundedCheck,
+ IconX,
+} from '@ui/icon';
+import { LightButton } from '@ui/input/LightButton/LightButton';
+import { LightIconButton } from '@ui/input/LightIconButton/LightIconButton';
+import { HorizontalSeparator } from '@ui/layout/HorizontalSeparator/HorizontalSeparator';
+import { useTheme } from '@ui/theme-constants';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import styles from './Toast.module.scss';
+import { type ToastProps } from './types/ToastProps';
+import { type ToastVariant } from './types/ToastVariant';
+
+const TOAST_ICONS = {
+ default: IconAlertTriangle,
+ error: IconAlertTriangle,
+ success: IconSquareRoundedCheck,
+ info: IconInfoCircle,
+ warning: IconAlertTriangle,
+} satisfies Record<ToastVariant, typeof IconAlertTriangle>;
+
+export const Toast = ({
+ children,
+ description,
+ icon,
+ iconLabel,
+ action,
+ progress,
+ duration = 6000,
+ onCancel,
+ onClose,
+ cancelLabel = 'Cancel',
+ closeLabel = 'Close',
+ variant = 'default',
+ role = 'status',
+ className,
+ onMouseEnter,
+ onMouseLeave,
+ render,
+ ref,
+ ...props
+}: ToastProps) => {
+ const theme = useTheme();
+ const [isPaused, setIsPaused] = useState(false);
+ const Icon = TOAST_ICONS[variant];
+
+ return useRender({
+ render,
+ ref,
+ props: {
+ role,
+ 'aria-live': role === 'alert' ? 'assertive' : 'polite',
+ ...props,
+ className: clsx(styles.root, className),
+ onMouseEnter: (event: MouseEvent<HTMLDivElement>) => {
+ setIsPaused(true);
+ onMouseEnter?.(event);
+ },
+ onMouseLeave: (event: MouseEvent<HTMLDivElement>) => {
+ setIsPaused(false);
+ onMouseLeave?.(event);
+ },
+ children: (
+ <>
+ <div className={styles.progress} aria-hidden>
+ <ProgressBar
+ barColor={theme.snackBar[variant].backgroundColor}
+ value={progress ?? 100}
+ countdownDurationInMs={isDefined(progress) ? undefined : duration}
+ isCountdownPaused={isPaused}
+ onCountdownComplete={onClose}
+ />
+ </div>
+ <div className={styles.header}>
+ <div className={styles.icon}>
+ {icon ?? (
+ <Icon
+ aria-label={iconLabel}
+ aria-hidden={!isDefined(iconLabel)}
+ color={theme.snackBar[variant].color}
+ size={theme.icon.size.md}
+ />
+ )}
+ </div>
+ <div className={styles.message}>{children}</div>
+ <div className={styles.actions}>
+ {isDefined(onCancel) && (
+ <LightButton title={cancelLabel} onClick={onCancel} />
+ )}
+ {isDefined(onClose) && (
+ <LightIconButton
+ title={closeLabel}
+ aria-label={closeLabel}
+ Icon={IconX}
+ onClick={onClose}
+ />
+ )}
+ </div>
+ </div>
+ {isDefined(description) && (
+ <div className={styles.description}>{description}</div>
+ )}
+ {isDefined(action) && (
+ <div className={styles.footer}>
+ <HorizontalSeparator noMargin />
+ <div className={styles.footerAction}>{action}</div>
+ </div>
+ )}
+ </>
+ ),
+ },
+ });
+};
diff --git a/packages/twenty-ui/src/feedback/Toast/__stories__/Toast.stories.tsx b/packages/twenty-ui/src/feedback/Toast/__stories__/Toast.stories.tsx
new file mode 100644
index 00000000000..29305d39aae
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/__stories__/Toast.stories.tsx
@@ -0,0 +1,223 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
+
+import { IconBell } from '@ui/icon';
+import { LightButton } from '@ui/input/LightButton/LightButton';
+import {
+ A11Y_DEFER_COLOR_CONTRAST,
+ CatalogDecorator,
+ type CatalogStory,
+ ComponentDecorator,
+} from '@ui/testing';
+
+import { Toast } from '../Toast';
+import { type ToastProps } from '../types/ToastProps';
+import { type ToastVariant } from '../types/ToastVariant';
+
+const meta: Meta<typeof Toast> = {
+ title: 'UI/Feedback/Toast',
+ component: Toast,
+ args: { children: 'Changes saved', progress: 100 },
+};
+
+export default meta;
+type Story = StoryObj<typeof Toast>;
+
+export const Default: Story = {
+ decorators: [ComponentDecorator],
+ args: { variant: 'success', onClose: fn() },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ expect(canvas.getByRole('status')).toHaveTextContent('Changes saved');
+ await userEvent.click(canvas.getByRole('button', { name: 'Close' }));
+ expect(args.onClose).toHaveBeenCalledOnce();
+ },
+};
+
+export const WithDescriptionAndAction: Story = {
+ ...Default,
+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
+ args: {
+ children: 'Record deleted',
+ description: 'You can undo this action.',
+ variant: 'info',
+ onCancel: fn(),
+ onClose: fn(),
+ cancelLabel: 'Annuler',
+ closeLabel: 'Fermer',
+ },
+ render: (args) => (
+ <Toast
+ {...args}
+ action={<LightButton title="Undo" onClick={args.onCancel} />}
+ />
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ expect(canvas.getByText('You can undo this action.')).toBeVisible();
+ await userEvent.click(canvas.getByRole('button', { name: 'Undo' }));
+ await userEvent.click(canvas.getByRole('button', { name: 'Annuler' }));
+ expect(args.onCancel).toHaveBeenCalledTimes(2);
+ await userEvent.click(canvas.getByRole('button', { name: 'Fermer' }));
+ expect(args.onClose).toHaveBeenCalledOnce();
+ },
+};
+
+export const CustomIconAndLink: Story = {
+ ...Default,
+ args: { icon: <IconBell size={16} />, onClick: fn() },
+ render: (args) => (
+ <Toast {...args} action={<a href="#record">View record</a>} />
+ ),
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const link = canvas.getByRole('link', { name: 'View record' });
+ expect(link).toHaveAttribute('href', '#record');
+ await userEvent.click(canvas.getByText('Changes saved'));
+ expect(args.onClick).toHaveBeenCalledOnce();
+ },
+};
+
+export const Alert: Story = {
+ ...Default,
+ args: { role: 'alert', variant: 'error', children: 'Unable to save' },
+ play: async ({ canvasElement }) => {
+ expect(within(canvasElement).getByRole('alert')).toHaveAttribute(
+ 'aria-live',
+ 'assertive',
+ );
+ },
+};
+
+const DismissibleToast = ({ onClose, ...props }: ToastProps) => {
+ const [isOpen, setIsOpen] = useState(true);
+
+ return (
+ <>
+ <button type="button" onClick={() => setIsOpen(true)}>
+ Show notification
+ </button>
+ {isOpen && (
+ <Toast
+ {...props}
+ onClose={() => {
+ onClose?.();
+ setIsOpen(false);
+ }}
+ />
+ )}
+ </>
+ );
+};
+
+export const Countdown: Story = {
+ ...Default,
+ args: { progress: undefined, duration: 600, onClose: fn() },
+ render: (args) => <DismissibleToast {...args} />,
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ expect(canvas.getByRole('status')).toBeVisible();
+ await waitFor(() => expect(args.onClose).toHaveBeenCalledOnce(), {
+ timeout: 3000,
+ });
+ expect(canvas.queryByRole('status')).not.toBeInTheDocument();
+ },
+};
+
+export const KeyboardDismissal: Story = {
+ ...Default,
+ render: (args) => <DismissibleToast {...args} />,
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ await userEvent.tab();
+ expect(
+ canvas.getByRole('button', { name: 'Show notification' }),
+ ).toHaveFocus();
+ await userEvent.tab();
+ expect(canvas.getByRole('button', { name: 'Close' })).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ expect(args.onClose).toHaveBeenCalledOnce();
+ expect(canvas.queryByRole('status')).not.toBeInTheDocument();
+ },
+};
+
+export const PauseOnHover: Story = {
+ ...Countdown,
+ args: {
+ ...Countdown.args,
+ duration: 1200,
+ onMouseEnter: fn(),
+ onMouseLeave: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const toast = canvas.getByRole('status');
+ await userEvent.hover(toast);
+ await new Promise((resolve) => setTimeout(resolve, 1400));
+ expect(toast).toBeVisible();
+ expect(args.onClose).not.toHaveBeenCalled();
+ expect(args.onMouseEnter).toHaveBeenCalledOnce();
+ await userEvent.unhover(toast);
+ expect(args.onMouseLeave).toHaveBeenCalledOnce();
+ await waitFor(() => expect(args.onClose).toHaveBeenCalledOnce(), {
+ timeout: 3000,
+ });
+ },
+};
+
+export const ExplicitProgress: Story = {
+ ...Countdown,
+ args: { progress: 40, duration: 100, onClose: fn() },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ await new Promise((resolve) => setTimeout(resolve, 300));
+ expect(canvas.getByRole('status')).toBeVisible();
+ expect(args.onClose).not.toHaveBeenCalled();
+ await userEvent.click(canvas.getByRole('button', { name: 'Close' }));
+ expect(args.onClose).toHaveBeenCalledOnce();
+ },
+};
+
+export const WithoutControls: Story = {
+ ...Default,
+ args: { onClose: undefined },
+ play: async ({ canvasElement }) => {
+ expect(within(canvasElement).queryByRole('button')).not.toBeInTheDocument();
+ },
+};
+
+export const Catalog: CatalogStory<Story, typeof Toast> = {
+ decorators: [CatalogDecorator],
+ args: { onClose: fn(), progress: 60 },
+ parameters: {
+ a11y: A11Y_DEFER_COLOR_CONTRAST,
+ catalog: {
+ dimensions: [
+ {
+ name: 'content',
+ values: ['notification'],
+ props: () => ({}),
+ },
+ {
+ name: 'variant',
+ values: [
+ 'default',
+ 'success',
+ 'error',
+ 'info',
+ 'warning',
+ ] satisfies ToastVariant[],
+ props: (variant: ToastVariant) => ({ variant }),
+ },
+ ],
+ options: { elementContainer: { style: { width: 310 } } },
+ },
+ },
+};
+
+export const CatalogDark: CatalogStory<Story, typeof Toast> = {
+ ...Catalog,
+ tags: ['!autodocs'],
+ globals: { colorScheme: 'dark' },
+};
diff --git a/packages/twenty-ui/src/feedback/Toast/__tests__/Toast.test.tsx b/packages/twenty-ui/src/feedback/Toast/__tests__/Toast.test.tsx
new file mode 100644
index 00000000000..d82816ff422
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/__tests__/Toast.test.tsx
@@ -0,0 +1,11 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { Toast } from '../Toast';
+import styles from '../Toast.module.scss';
+
+runComponentConformance({
+ name: 'Toast',
+ element: <Toast progress={100}>Changes saved</Toast>,
+ refInstanceOf: HTMLDivElement,
+ ownClassName: styles.root,
+});
diff --git a/packages/twenty-ui/src/feedback/Toast/types/ToastProps.ts b/packages/twenty-ui/src/feedback/Toast/types/ToastProps.ts
new file mode 100644
index 00000000000..f2abcb75cb3
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/types/ToastProps.ts
@@ -0,0 +1,19 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ComponentPropsWithRef, type ReactNode } from 'react';
+
+import { type ToastVariant } from './ToastVariant';
+
+export type ToastProps = ComponentPropsWithRef<'div'> & {
+ render?: useRender.RenderProp;
+ variant?: ToastVariant;
+ description?: ReactNode;
+ icon?: ReactNode;
+ iconLabel?: string;
+ action?: ReactNode;
+ progress?: number;
+ duration?: number;
+ onCancel?: () => void;
+ onClose?: () => void;
+ cancelLabel?: string;
+ closeLabel?: string;
+};
diff --git a/packages/twenty-ui/src/feedback/Toast/types/ToastVariant.ts b/packages/twenty-ui/src/feedback/Toast/types/ToastVariant.ts
new file mode 100644
index 00000000000..ac55b56d95c
--- /dev/null
+++ b/packages/twenty-ui/src/feedback/Toast/types/ToastVariant.ts
@@ -0,0 +1 @@
+export type ToastVariant = 'default' | 'error' | 'success' | 'info' | 'warning';
diff --git a/packages/twenty-ui/src/feedback/index.ts b/packages/twenty-ui/src/feedback/index.ts
index 3e300690e71..0b9dae403f6 100644
--- a/packages/twenty-ui/src/feedback/index.ts
+++ b/packages/twenty-ui/src/feedback/index.ts
@@ -38,3 +38,6 @@ export type { ProgressBarProps } from './ProgressBar/ProgressBar';
export { ProgressBar } from './ProgressBar/ProgressBar';
export type { SidePanelInformationBannerProps } from './SidePanelInformationBanner/SidePanelInformationBanner';
export { SidePanelInformationBanner } from './SidePanelInformationBanner/SidePanelInformationBanner';
+export { Toast } from './Toast/Toast';
+export type { ToastProps } from './Toast/types/ToastProps';
+export type { ToastVariant } from './Toast/types/ToastVariant';