Skip to content

Overlays

Toast

Bundle size
10.5 KB
3.0.0

Displays a message for a short period of time.

This component is our take on Sonner, developed and maintained by Emil.

Unlike a Dialog, Toast does not interrupt the user’s experience but complements the action he just performed. Unlike other options you may find out there, this one limits the number of messages that can be displayed at the same time, preventing the interface from becoming cluttered - in addition to being highly customizable.

All messages can be controlled with gestures such as swipe and click on mobile. When clicking on a toast, all messages are expanded. When performing the swipe down movement, the message is discarded.

Terminal window
pnpm add @inpulse-ui/toast

Set some defaults for all the toast notifications.

PropTypeDefault ValueRequired
expandbooleanfalseNo
gapnumber14No
mobileOffsetstring | number | object16pxNo
offsetstring | number | object32pxNo
positionenumNo
toastOptionsobject-No
richColorsbooleanfalseNo
visibleToastsnumber3No

Defines configurations for a single toast notification.

PropTypeDefault ValueRequired
closeButtonbooleanfalseNo
dismissiblebooleantrueNo
durationnumber4000No
onAutoClosefunction-No
onDismissfunction-No

The Toaster component is responsible for rendering messages. It can be inserted anywhere in the application, even on the server side as in Next.js’ layout.tsx.

import { Toaster } from '@inpulse-ui/toast';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="pt-br">
<body>
{children}
<Toaster />
</body>
</html>
);
}

After that, simply activate the toast method - which is also exported by DS - passing the message you want to display.

import { toast } from '@inpulse-ui/toast';
toast("Hello, world!");

It is possible to use a Promise to wait for the toast to close.

It is possible to change the duration of the toast through the duration property, directly in the toast method.

toast('Hello, world!', { duration: 5000 });

It is possible to change the position of the toast through the position property, which can be applied to the Toaster component.

<Toaster position="top-left" />

It is also possible to change the position of each message individually. To do this, simply pass the position property directly into the toast method. This way, the position of the other toasts will not be affected.

toast('Hello, world!', { position: 'top-right' });

It is possible to apply colors to toast through the richColors property. Without this, messages will come in the default color, only the iconography will change.

<Toaster richColors />

Project

Built with by Jo Santana in Brazil.

© 2026 Inpulse. All rights reserved.