CoreUI for Vue.js logo
Angular JavaScript / Vanilla JS React.js
  • undefinedGetting started
  • undefinedCustomize
  • undefinedLayout
  • undefinedForms
  • undefinedComponents
  • undefinedTemplates
  • undefinedMigration
  • undefined
  • undefined
  • undefined
undefinedDownloadundefinedHire Us Get CoreUI PRO

Support CoreUI Development

CoreUI is an MIT-licensed open source project and is completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.

You can support our Open Source software development in the following ways:

  • Buy the CoreUI PRO, and get access to PRO components, and dedicated support.
  • Hire Us! We create stunning designs, high-conversion landing pages, functional mobile apps and reliable web services – everything you need to offer your products or services online and always stay a tap away from your customers.
  • Give us a star ⭐️ on Github.

Vue Toast Component

Push notifications to your visitors with a toast, a lightweight and easily customizable alert message.

Other frameworks

CoreUI components are available as native Angular, Bootstrap (Vanilla JS), and React components. To learn more please visit the following pages.

  • Angular Toast
  • Bootstrap Toast
  • React Toast

Vue toasts are lightweight notifications designed to mimic the push notifications that have been popularized by mobile and desktop operating systems. They’re built with flexbox, so they’re easy to align and position.

Overview #

Things to know when using the toast plugin:

  • Toasts are opt-in for performance reasons, so you must initialize them yourself.
  • Toasts will automatically hide if you do not specify autohide: false.

Examples #

Basic #

To encourage extensible and predictable toasts, we recommend a header and body. Toast headers use display: flex, allowing easy alignment of content thanks to our margin and flexbox utilities.

Toasts are as flexible as you need and have very little required markup. At a minimum, we require a single element to contain your "toasted" content and strongly encourage a dismiss button.

CoreUI for Vue.js7 min ago
Hello, world! This is a toast message.
<CToast :autohide="false">
  <CToastHeader closeButton>
    <svg
      class="rounded me-2"
      width="20"
      height="20"
      xmlns="http://www.w3.org/2000/svg"
      preserveAspectRatio="xMidYMid slice"
      focusable="false"
      role="img"
    >
      <rect width="100%" height="100%" fill="#007aff"></rect>
    </svg>
    <span class="me-auto fw-bold">CoreUI for Vue.js</span>
    <small>7 min ago</small>
  </CToastHeader>
  <CToastBody>Hello, world! This is a toast message.</CToastBody>
</CToast>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<template>
  <CButton color="primary" @click="createToast">Send a toast</CButton>
  <CToaster placement="top-end">
    <CToast v-for="(toast, index) in toasts">
      <CToastHeader closeButton>
      <span class="me-auto fw-bold">{{toast.title}}</span>
      <small>7 min ago</small>
      </CToastHeader>
      <CToastBody>
        {{ toast.content }}
      </CToastBody>  
    </CToast>
  </CToaster>
</template>
<script>
  export default {
    data() {
      return {
        toasts: []
      }
    },
    methods: {
      createToast() {
        this.toasts.push({
          title: 'new toast',
          content: 'Lorem ipsum dolor cet emit'
        })
      }
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

Translucent #

Toasts are slightly translucent to blend in with what's below them.

CoreUI for Vue.js7 min ago
Hello, world! This is a toast message.
<CToast :autohide="false">
  <CToastHeader closeButton>
    <svg
      class="rounded me-2"
      width="20"
      height="20"
      xmlns="http://www.w3.org/2000/svg"
      preserveAspectRatio="xMidYMid slice"
      focusable="false"
      role="img"
    >
      <rect width="100%" height="100%" fill="#007aff"></rect>
    </svg>
    <span class="me-auto fw-bold">CoreUI for Vue.js</span>
    <small>7 min ago</small>
  </CToastHeader>
  <CToastBody>Hello, world! This is a toast message.</CToastBody>
</CToast>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Stacking #

You can stack toasts by wrapping them in a toast container, which will vertically add some spacing.

CoreUI for Vue.js7 min ago
Hello, world! This is a toast message.
CoreUI for Vue.js7 min ago
Hello, world! This is a toast message.
<CToaster>
  <CToast :autohide="false">
    <CToastHeader closeButton>
      <svg
        class="rounded me-2"
        width="20"
        height="20"
        xmlns="http://www.w3.org/2000/svg"
        preserveAspectRatio="xMidYMid slice"
        focusable="false"
        role="img"
      >
        <rect width="100%" height="100%" fill="#007aff"></rect>
      </svg>
      <span class="me-auto fw-bold">CoreUI for Vue.js</span>
      <small>7 min ago</small>
    </CToastHeader>
    <CToastBody>Hello, world! This is a toast message.</CToastBody>
  </CToast>
  <CToast :autohide="false">
    <CToastHeader closeButton>
      <svg
        class="rounded me-2"
        width="20"
        height="20"
        xmlns="http://www.w3.org/2000/svg"
        preserveAspectRatio="xMidYMid slice"
        focusable="false"
        role="img"
      >
        <rect width="100%" height="100%" fill="#007aff"></rect>
      </svg>
      <span class="me-auto fw-bold">CoreUI for Vue.js</span>
      <small>7 min ago</small>
    </CToastHeader>
    <CToastBody>Hello, world! This is a toast message.</CToastBody>
  </CToast>
</CToaster>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

Custom content #

Customize your toasts by removing sub-components, tweaking them with utilities, or by adding your own markup. Here we've created a simpler toast by removing the default <CToastHeader>, adding a custom hide icon from CoreUI Icons, and using some flexbox utilities to adjust the layout.

Hello, world! This is a toast message.
<CToast :autohide="false" class="align-items-center">
  <div class="d-flex">
    <CToastBody>Hello, world! This is a toast message.</CToastBody>
    <CToastClose class="me-2 m-auto"/>
  </div>
</CToast>
1
2
3
4
5
6

Alternatively, you can also add additional controls and components to toasts.

Hello, world! This is a toast message.
<CToast :autohide="false" class="align-items-center">
  <CToastBody>
    Hello, world! This is a toast message.
    <div class="mt-2 pt-2 border-top">
    <CButton type="button" color="primary" size="sm">
    Take action
    </CButton>
    <CToastClose component="CButton" color="secondary" size="sm" class="ms-1">Close</CToastClose>
    </div>
  </CToastBody>
</CToast>
1
2
3
4
5
6
7
8
9
10
11

Color schemes #

Building on the above example, you can create different toast color schemes with our color and background utilities. Here we've set color="primary" and added .text-white class to the <Ctoast>, and then set white property to our close button. For a crisp edge, we remove the default border with .border-0.

Hello, world! This is a toast message.
<CToast :autohide="false" color="primary" class="text-white align-items-center">
  <div class="d-flex">
    <CToastBody>Hello, world! This is a toast message.</CToastBody>
    <CToastClose class="me-2 m-auto" white />
  </div>
</CToast>
1
2
3
4
5
6

Customizing #

CSS variables #

Vue toasts use local CSS variables on .toast for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

--cui-toast-padding-x: #{$toast-padding-x};
--cui-toast-padding-y: #{$toast-padding-y};
--cui-toast-spacing: #{$toast-spacing};
--cui-toast-max-width: #{$toast-max-width};
--cui-toast-font-size: #{$toast-font-size};
--cui-toast-color: #{$toast-color};
--cui-toast-bg: #{$toast-background-color};
--cui-toast-border-width: #{$toast-border-width};
--cui-toast-border-color: #{$toast-border-color};
--cui-toast-border-radius: #{$toast-border-radius};
--cui-toast-box-shadow: #{$toast-box-shadow};
--cui-toast-header-color: #{$toast-header-color};
--cui-toast-header-bg: #{$toast-header-background-color};
--cui-toast-header-border-color: #{$toast-header-border-color};
1
2
3
4
5
6
7
8
9
10
11
12
13
14

How to use CSS variables #

const vars = { 
  '--my-css-var': 10,
  '--my-another-css-var': "red" 
}
return <CToast :style="vars">...</CToast>
1
2
3
4
5

SASS variables #

$toast-max-width:                   350px;
$toast-padding-x:                   .75rem;
$toast-padding-y:                   .5rem;
$toast-font-size:                   .875rem;
$toast-color:                       unset;
$toast-background-color:            rgba($white, .85);
$toast-border-width:                $border-width;
$toast-border-color:                var(--cui-border-color-translucent);
$toast-border-radius:               $border-radius;
$toast-box-shadow:                  $box-shadow;
$toast-spacing:                     $container-padding-x;

$toast-header-color:                $gray-600;
$toast-header-background-color:     rgba($white, .85);
$toast-header-border-color:         rgba($black, .05);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

API #

CToast #

import { CToast } from '@coreui/vue'
// or
import CToast from '@coreui/vue/src/components/toast/CToast'
1
2
3

Props #

Prop nameDescriptionTypeValuesDefault
autohideAuto hide the toast.boolean-true
colorSets the color context of the component to one of CoreUI’s themed colors.string'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light', string
delayDelay hiding the toast (ms).number-5000
dismissibleOptionally add a close button to component and allow it to self dismiss.boolean-true
indexindex of the component.number--
titleTitle node for your component.string--
visibleToggle the visibility of component.boolean-true

Events #

Event nameDescriptionProperties
closeCallback fired when the component requests to be closed.
showCallback fired when the component requests to be shown.

CToastClose #

import { CToastClose } from '@coreui/vue'
// or
import CToastClose from '@coreui/vue/src/components/toast/CToastClose'
1
2
3

Props #

Prop nameDescriptionTypeValuesDefault
componentComponent used for the root node. Either a string to use a HTML element or a component.string--

Events #

Event nameDescriptionProperties
closeEvent called before the dissmiss animation has started.

CToastHeader #

import { CToastHeader } from '@coreui/vue'
// or
import CToastHeader from '@coreui/vue/src/components/toast/CToastHeader'
1
2
3

Props #

Prop nameDescriptionTypeValuesDefault
close-buttonAutomatically add a close button to the header.boolean-

Events #

Event nameDescriptionProperties
closeEvent called after clicking the close button.

CToaster #

import { CToaster } from '@coreui/vue'
// or
import CToaster from '@coreui/vue/src/components/toast/CToaster'
1
2
3

Props #

Prop nameDescriptionTypeValuesDefault
placementDescribes the placement of component.string'top-start', 'top', 'top-end', 'middle-start', 'middle', 'middle-end', 'bottom-start', 'bottom', 'bottom-end'-
On this page
  • Overview
  • Examples
    • Basic
    • Translucent
    • Stacking
    • Custom content
    • Color schemes
  • Customizing
    • CSS variables
    • SASS variables
  • API
    • CToast
    • CToastClose
    • CToastHeader
    • CToaster
  • GitHub
  • Twitter
  • CoreUI (Vanilla)
  • CoreUI for Angular
  • CoreUI for React.js

CoreUI for Vue is Open Source UI Components Library for Vue.js.

CoreUI code licensed MIT, docs CC BY 3.0. CoreUI PRO requires a commercial license.