Toast

Notices that stack in a corner and fan out on hover, swipe away, and can be pinned to the control that caused them.

01Preview

01
Full screen

02Installation

npx shadcn@latest add https://aiellie.app/r/toast.json

03API reference

11
From the Base UI documentation

Groups all parts of an individual toast. Renders a <div> element.

Props

PropTypeDefaultDescription
swipeDirection'up' | 'down' | 'left' | 'right' | ('left' | 'right' | 'up' | 'down')[]['down', 'right']Direction(s) in which the toast can be swiped to dismiss.
toast\*Toast.Root.ToastObject-The toast to render.
classNamestring | ((state: Toast.Root.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component's state.
styleReact.CSSProperties | ((state: Toast.Root.State) => React.CSSProperties | undefined)-Style applied to the element, or a function that returns a style object based on the component's state.
renderReactElement | ((props: HTMLProps, state: Toast.Root.State) => ReactElement)-Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.

Data Attributes

AttributeTypeDescription
data-expandedbooleanPresent when the toast is expanded in the viewport.
data-limitedbooleanPresent when the toast was limited because the toast limit was exceeded.
data-swipe-direction'up' | 'down' | 'left' | 'right'The direction the toast was swiped.
data-swipingbooleanPresent when the toast is being swiped.
data-typestringThe type of the toast.
data-starting-style-Present when the toast begins animating in.
data-ending-style-Present when the toast is animating out.

CSS Variables

VariableTypeDescription
--toast-heightnumberIndicates the measured natural height of the toast in pixels.
--toast-indexnumberIndicates the index of the toast in the list.
--toast-offset-ynumberIndicates the vertical pixels offset of the toast in the list when expanded.
--toast-swipe-movement-xnumberIndicates the horizontal swipe movement of the toast.
--toast-swipe-movement-ynumberIndicates the vertical swipe movement of the toast.