API reference API reference Everything exported by qwik-sonner 1.x: Toaster, toast and the Toast, ExternalToast and ToasterProps types.
toast ( message , options ? )
toast . message ( message , options ? )
toast . success ( message , options ? )
toast . info ( message , options ? )
toast . warning ( message , options ? )
toast . error ( message , options ? )
toast . loading ( message , options ? )
toast . promise ( promise , data )
toast . custom ( ( id ) = > jsx , options ? )
toast . dismiss ( id ? ) import { $ } from " @builder.io/qwik " ;
toast ( " Event has been created " , {
action : {
label : " Undo " ,
onClick$ : $ ( ( ) = > console . log ( " Undo " ) ) ,
} ,
} ) ; import { $ } from " @builder.io/qwik " ;
toast . promise ( ( ) = > new Promise ( ( resolve ) = > setTimeout ( resolve , 2000 ) ) , {
loading : " Loading… " ,
success : $ ( ( data ) = > ` ${ data . name } has been added! ` ) ,
error : " Error " ,
} ) ; Field Type Default loadingstring— Loading message. successstring | JSXOutput | QRL<(data) => …>— Shown on resolve. errorstring | JSXOutput | QRL<(error) => …>— Shown on reject. descriptionstring | JSXOutput | QRL<(data) => …>— Description of the settled toast. finally() => void | Promise<void>— Runs when the promise settles.
toast ( < div > My custom toast </ div > ) ;
toast . custom ( ( id ) = > (
< div >
< h1 > Custom toast </ h1 >
< button onClick$ = { ( ) = > toast . dismiss ( id ) } > Dismiss </ button >
</ div >
) ) ; const toastId = toast ( " Sonner " ) ;
toast . success ( " Toast has been updated " , { id : toastId } ) ;
toast . dismiss ( toastId ) ;
toast . dismiss ( ) ; toast ( " Event has been created " , {
onDismiss$ : $ ( ( t ) = > console . log ( ` Toast ${ t . id } has been dismissed ` ) ) ,
onAutoClose$ : $ ( ( t ) = > console . log ( ` Toast ${ t . id } has been closed automatically ` ) ) ,
} ) ; Prop Type Default positionPosition"bottom-right"Corner the toasts stack in. theme"light" | "dark" | "system""light"Color scheme. richColorsbooleanfalseColored success/error/info/warning toasts. invertboolean | Signal<boolean>falseInvert toast colors. expandbooleanfalseExpand all toasts. visibleToastsnumber3Toasts visible at once. closeButtonbooleanfalseClose button on every toast. durationnumber4000Default duration in ms. gapnumber14Gap between expanded toasts (px). offsetstring | number"32px"Distance from the viewport edges. dir"rtl" | "ltr" | "auto""auto"Text direction. hotkeystring[]["altKey", "KeyT"]Keys that focus the toasts. toastOptionsToastOptions— Defaults for every toast: class, descriptionClass, style, actionButtonStyle, cancelButtonStyle, duration, unstyled, classes, closeButton. iconsToastIcons— Components for success, info, warning, error, loading. containerAriaLabelstring"Notifications"Label of the toasts region. pauseWhenPageIsHiddenboolean— Pause timers while the tab is hidden. class / stylestring / CSSProperties— Applied to the toast list. loadingIconDeprecated Component— Use icons.loading.
Option Type Default idstring | number— Reuse to update an existing toast. descriptionstring | JSXOutput— Second line. Strings are parsed as sanitized HTML. durationnumber4000Use Number.POSITIVE_INFINITY to persist. iconComponent— Custom icon component. action / cancelAction | JSXOutput— { label, onClick$, preventDefault? } or JSX.closeButtonboolean— Override the Toaster's close button. dismissiblebooleantrueAllow swiping / closing. importantboolean— Announce with aria-live="assertive". positionPosition— Override the Toaster position. invertboolean— Invert this toast's colors. onDismiss$QRL<(toast) => unknown>— Close button clicked or toast swiped. onAutoClose$QRL<(toast) => unknown>— Timer ran out. unstyledboolean— Drop the default styles. class / descriptionClass / classesstring / string / ToastClassnames— Classes for the toast and its parts. style / actionButtonStyle / cancelButtonStyleCSSProperties— Inline styles.