um

Toast

Flashes and stream responses as toasts that dismiss themselves, pause while hovered or focused, and survive Drive visits and morph refreshes.

JavaScript API

Show, update and dismiss notifications without a server request. Try an async action, a rejected action, or a scoped panel.

Show a notification, then update or dismiss it.

Rails and JavaScript together

The response gives the toast a logical id. JavaScript can dismiss it using that id.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

From a flash, after a redirect

Each button sets flash[type] and redirects back. Hover a toast to hold it open.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

From a stream response

turbo_stream.toast pops one without a redirect.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Title, icon and action

A heading adds context; actions are ordinary Rails buttons or links.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Image and actions

A toast can contain a title, description, image, and buttons.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Upload in progress

A progress component inside a toast appears in the top-right stack.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Tones

Good, warn, bad and info, plus neutral, accent and inverted surfaces.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Six positions

Place each toast independently. Start and end follow the reading direction.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Duration and sticky toasts

Mix timed and sticky messages. A duration of 0 waits for the dismiss button.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Widths

Short, long or a pixel width; each stays within the screen on a phone.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Action layouts

Give horizontal actions room with width: :long, or place them below with layout: :vertical. Narrow toasts stack automatically. close_button: false hides the × when a Dismiss action is provided.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Custom leading content

Use the leading slot for an avatar or other context instead of the default icon.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Custom content

Capture a body slot for a composed announcement. The close button stays available.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Inside a panel

A named, scoped mount contains notifications within a positioned panel.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

Above an open dialog

A toast streamed from a dialog shows above it, and times out even though the dialog makes it inert.

This example talks to a server

These are static pages, so what this example saves, posts or searches for won't answer here. Run the browser (bin/dev) or mount it in an app to try it for real.

A dialog

A toast streamed from in here shows above the dialog, not under its backdrop. It can't be hovered or dismissed until the dialog closes, but it still times out on its own.