Revel
GitHub
GitHub
  • Overview

    • Getting started
    • FAQ
    • Release notes
  • Foundations

    • Meet the standard
    • Accessibility
    • Internationalization
    • Information hierarchy
    • Speed
  • Design

    • Visual principles
    • Colors
    • Space
    • Icons
    • Typography
  • Design tokens
  • Style helpers
  • Content

    • Express your ideas
    • Actionable language
    • Inclusive and accessible language
    • Alternative text
    • Grammar and mechanics
      • Basics
      • Capitalization
      • Dates and units of measurement
      • Punctuation
  • Components

    • Alert
    • Avatar
    • Badge
    • Button
    • Button group
    • Checkbox
    • Date Input
      • dates
      • datetimes
      • ranges
    • Field group
    • File upload
    • Flex
    • Grid
    • Icon
    • Image
    • Input
    • Loader
    • Modal
    • Month picker
    • Pagination
    • Popper
    • Radio
    • Repeater
    • Select
    • Tabs
    • Tile
    • Toast
    • Toggle
  • Directives

    • Click outside
    • Tooltip

Toast

RToast component is used to show quick messages that temporarily appear in the top right zone of the screen.

Usage

Revel provides createRToastManager to create a toast manager instance to open toasts from your components like this:

const toast = createRToastManager(...);
toast.positive('Something positive in your code');

Options API

Our legacy Vue 2 projects are using this.$toast so, in order to keep backwards compatibility, Revel automatically registers a toast manager instance on installation:

  app.config.globalProperties.$toast = createRToastManager(app);

This means that old this.$toast will keep on working after migrating to the new Revel.

Composition API

Instead of using the previous Vue.prototype scape hatch, in composition API, you can simply create a singleton toast instance that you import from setup method (check this implementation in the last example). You could also use provide/inject but, it is more verbose and probably less clear.

Examples

Options API

toast-all-types.vue

You can also create custom dynamic html messages by passing a render function in the message prop.

toast-message-function.vue

Composition API

This example import a toast instance singleton from composition API.

toast-composition-api.vue

API

Props

NameTypeDefaultDescription
typeToastType'positive'

Specify toast type according to your theme colors

titlestring''

Change the toast title

messageunion, string, TSParenthesizedType''

Change the toast message

allowClosebooleantrue

Specify if the user is allowed to close the toast

visiblebooleantrue

Specify is the toast visible

autoHidebooleantrue

Specify does the toast hide

hideDelaynumber5000

Specify a hide delay time, ms

containerNullable, HTMLElementnull

Pass HTML element to append the toast to

Events

NameDescription
hide
Edit this page
Last Updated: 7/23/24, 9:07 PM
Contributors: Alberto Gualis, John Hannagan, Cesar Level, Weetbix
Prev
Tile
Next
Toggle