Skip to Content

Toast

A feedback component displaying brief, self-destructing notification prompts at the corners of viewports. 
For more information on this component configuration, visit Radix UI 

Placement

Use the placement prop on the Toast.Provider to set the placement of the Toast. Values can include top-start, top, top-end, bottom-start, bottom, bottom-end.







Sizes

Use the toast-{size} class to control the component size.

Size values can include:smmd.

For more information on all available sizing utilities, visit Tailwind 

With Accent

Use the decoration-accent-{position} class to add a decorative accent to the component. Refer to the Accents  section for more information.

Variants

Use the variant and palette classes to control the appereance of the component.

Variant values can include solidoutlinesurfacesubtleplain.
Color palettes can include primaryneutral. For extra palettes such as warning error and more, refer to the Colors section.

Customizing

globals.css
:root { --ex-toast-viewport-px: calc(var(--spacing) * 6); --ex-toast-viewport-py: calc(var(--spacing) * 6); --ex-toast-z-index: 55; --ex-toast-font-size-sm: var(--text-xs); --ex-toast-font-size-md: var(--text-sm); --ex-toast-max-w-sm: var(--container-3xs); --ex-toast-max-w-md: var(--container-2xs); --ex-toast-gap-x-sm: calc(var(--spacing) * 2); --ex-toast-gap-x-md: calc(var(--spacing) * 2.5); --ex-toast-px-sm: calc(var(--spacing) * 3); --ex-toast-px-md: calc(var(--spacing) * 4); --ex-toast-py-sm: calc(var(--spacing) * 3); --ex-toast-py-md: calc(var(--spacing) * 4); --ex-toast-radius-sm: var(--radius-sm); --ex-toast-radius-md: var(--radius-sm); --ex-toast-shadow-sm: var(--shadow-sm); --ex-toast-shadow-md: var(--shadow-sm); --ex-toast-indicator-font-size-sm: var(--text-lg); --ex-toast-indicator-font-size-md: var(--text-xl); --ex-toast-content-gap-x-sm: calc(var(--spacing) * 1.5); --ex-toast-content-gap-x-md: calc(var(--spacing) * 2); --ex-toast-content-gap-y-sm: calc(var(--spacing) * 2); --ex-toast-content-gap-y-md: calc(var(--spacing) * 2); --ex-toast-title-font-family: var(--font-sans); --ex-toast-title-font-weight: var(--font-weight-semibold); --ex-toast-title-font-size-sm: var(--text-sm); --ex-toast-title-font-size-md: var(--text-base); --ex-toast-description-font-family: var(--font-sans); --ex-toast-description-font-weight: var(--font-weight-normal); --ex-toast-description-opacity: var(--ex-options-opacity-muted); --ex-toast-description-font-size-sm: var(--text-xs); --ex-toast-description-font-size-md: var(--text-sm); --ex-toast-indicator-font-size-sm: var(--text-lg); --ex-toast-indicator-font-size-md: var(--text-xl); }

API

For more information on this component configuration, visit Radix UI 

Toast Provider

PropTypeDefault
durationnumber5000
swipeDirectionenum of ["up", "down", "left", "right"]right
swipeThresholdnumber50

Toast

ElementSelector
Toast.ex-toast
PropTypeDefault
asElementTypediv
asChildbooleanfalse
defaultOpenbooleantrue
durationnumber
forceMountbooleanfalse
openboolean
typeenum of ["background", "foreground"]foreground
onPausefunction
onResumefunction
onSwipeStartfunction
onSwipeMovefunction
onSwipeEndfunction
onSwipeCancelfunction
onOpenChangefunction

Toast Viewport

ElementSelector
Toast.Viewport.ex-toast-viewport
PropTypeDefault
asElementTypediv
asChildbooleanfalse

Toast Content

ElementSelector
Toast.Content.ex-toast-content
PropTypeDefault
asElementTypediv
asChildbooleanfalse

Toast Title

ElementSelector
Toast.Title.ex-toast-title
PropTypeDefault
asElementTypeh4
asChildbooleanfalse

Toast Description

ElementSelector
Toast.Description.ex-toast-description
PropTypeDefault
asElementTypep
asChildbooleanfalse

Toast Action

ElementSelector
Toast.Action.ex-toast-action
PropTypeDefault
asElementTypediv
asChildbooleanfalse
altTextstringaction

Toast Close

ElementSelector
Toast.Close.ex-toast-close
PropTypeDefault
asElementTypediv
asChildbooleanfalse
Last updated on