Back to Tooljet

Sonner — Rocket Design Spec

frontend/src/components/ui/Rocket/Sonner/Sonner.spec.md

3.20.154-lts3.0 KB
Original Source

Sonner — Rocket Design Spec

<!-- figma: https://www.figma.com/design/SZKm4ecuzgBwFq0v4sfrO5/Sanitation---Miscellaneous?node-id=2868-334374 --> <!-- synced: 2026-04-02 -->

Overview

Sonner is the toast notification system for Rocket. It wraps the sonner library with ToolJet tokens. Consists of two parts:

  1. <Toaster /> — provider component, placed once in the app root
  2. toast() — imperative API to trigger toasts from anywhere

Toaster Props

PropTypeValuesDefault
positionstringtop-center | top-right | bottom-right | etc.top-center
closeButtonbooleantrue
richColorsbooleantrue
durationnumberms4000

Toast Types

TypeIconColor intent
defaultnoneneutral (surface bg)
successCircleCheckIcongreen/success
errorOctagonXIconred/danger
warningTriangleAlertIconorange/warning
infoInfoIconblue/brand
loadingLoader2Icon (spinning)neutral

Token Mapping (from Figma)

ElementFigma tokenToolJet class
toast bgBase/Light/white 00tw-bg-background-surface-layer-01
toast borderslate/light/05 (#E6E8EB)tw-border-solid tw-border tw-border-border-weak
toast shadowShadow/06 (0 32 64 -12)tw-shadow-[0px_32px_64px_-12px_rgba(16,24,40,0.14)]
toast radius6pxtw-rounded-md
toast padding16pxtw-p-4
toast text14px Medium / 20px (slate/light/12)tw-font-title-large tw-text-text-default
icon gap8pxtw-gap-2
close iconslate/light/09 (#889096)tw-text-icon-default
close icon size16pxtw-size-4
type icon size20pxtw-size-5

Usage Pattern

jsx
// In app root (once)
<Toaster />

// Anywhere in the app
import { toast } from 'sonner';

toast('Default notification');
toast.success('Item saved');
toast.error('Workspace already exists');
toast.warning('Proceed with caution');
toast.info('New version available');
toast.loading('Uploading...');

// With description
toast.success('Saved', { description: 'Your changes have been saved.' });

// With action
toast('Item deleted', {
  action: { label: 'Undo', onClick: () => undoDelete() },
});

CVA Shape

Shape D — no CVA. Sonner handles its own rendering. Rocket HOC overrides styles via toastOptions.classNames and inline style variables.

Notes

  • sonner library handles all toast rendering, stacking, swipe-to-dismiss, and auto-dismiss.
  • No next-themes — ToolJet uses .dark-theme class. Theme not passed to sonner.
  • Icons from lucide-react — type icons are 20px (tw-size-5), close icon is 16px (tw-size-4).
  • closeButton={true} by default — all toasts get a close button.
  • Position defaults to top-center.
  • richColors={true} enables sonner's built-in semantic coloring for typed toasts.
  • Shadow is heavier than standard elevation tokens — uses custom shadow from Figma.
  • Typography uses tw-font-title-large (14px Medium / 20px) — not the default body font.