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 Alert Component

Vue alert component gives contextual feedback information for common user operations. The alert component is delivered with a bunch of usable and adjustable alert messages.

Other frameworks

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

  • Angular Alert
  • Bootstrap Alert
  • React Alert

Examples #

Vue Alert is prepared for any length of text, as well as an optional close button. For a styling, use one of the required contextual color props (e.g., primary). For inline dismissal, use the dismissing prop.

A simple primary alert—check it out!
A simple secondary alert—check it out!
A simple success alert—check it out!
A simple danger alert—check it out!
A simple warning alert—check it out!
A simple info alert—check it out!
A simple light alert—check it out!
A simple dark alert—check it out!
<CAlert color="primary">A simple primary alert—check it out!</CAlert>
<CAlert color="secondary">A simple secondary alert—check it out!</CAlert>
<CAlert color="success">A simple success alert—check it out!</CAlert>
<CAlert color="danger">A simple danger alert—check it out!</CAlert>
<CAlert color="warning">A simple warning alert—check it out!</CAlert>
<CAlert color="info">A simple info alert—check it out!</CAlert>
<CAlert color="light">A simple light alert—check it out!</CAlert>
<CAlert color="dark">A simple dark alert—check it out!</CAlert>
1
2
3
4
5
6
7
8

Live example #

Click the button below to show an alert (hidden with inline styles to start), then dismiss (and destroy) it with the built-in close button.

<CAlert color="primary" :visible="liveExampleVisible" dismissible @close="() => { liveExampleVisible = false }">A simple primary alert—check it out!</CAlert>
<CButton color="primary" @click="() => { liveExampleVisible = true }">Show live alert</CButton>
1
2

Link color #

Use the <CAlertLink> component to immediately give matching colored links inside any alert.

A simple primary alert with an example link. Give it a click if you like.
A simple secondary alert with an example link. Give it a click if you like.
A simple success alert with an example link. Give it a click if you like.
A simple danger alert with an example link. Give it a click if you like.
A simple warning alert with an example link. Give it a click if you like.
A simple info alert with an example link. Give it a click if you like.
A simple light alert with an example link. Give it a click if you like.
A simple dark alert with an example link. Give it a click if you like.
<CAlert color="primary">
  A simple primary alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="secondary">
  A simple secondary alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="success">
  A simple success alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="danger">
  A simple danger alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="warning">
  A simple warning alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="info">
  A simple info alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="light">
  A simple light alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
<CAlert color="dark">
  A simple dark alert with <CAlertLink href="#">an example link</CAlertLink>. Give it a click if you like.
</CAlert>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

Additional content #

Alert can also incorporate supplementary HTML elements like heading, paragraph, and divider.

Well done!

Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.


Whenever you need to, be sure to use margin utilities to keep things nice and tidy.

<CAlert color="success" v-bind:visible="true">
  <CAlertHeading>Well done!</CAlertHeading>
  <p>Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.</p>
  <hr />
  <p class="mb-0">Whenever you need to, be sure to use margin utilities to keep things nice and tidy.</p>
</CAlert>
1
2
3
4
5
6

Icons #

Similarly, you can use flexbox utilities and CoreUI Icons to create alerts with icons. Depending on your icons and content, you may want to add more utilities or custom styles.

An example alert with an icon
<CAlert color="primary" class="d-flex align-items-center">
  <svg class="flex-shrink-0 me-2" width="24" height="24" viewBox="0 0 512 512">
    <rect width="32" height="176" x="240" y="176" fill="var(--ci-primary-color, currentColor)" class="ci-primary"></rect><rect width="32" height="32" x="240" y="384" fill="var(--ci-primary-color, currentColor)" class="ci-primary"></rect><path fill="var(--ci-primary-color, currentColor)" d="M274.014,16H237.986L16,445.174V496H496V445.174ZM464,464H48V452.959L256,50.826,464,452.959Z" class="ci-primary"></path>
  </svg>
  <div>
    An example alert with an icon
  </div>
</CAlert>
1
2
3
4
5
6
7
8

Need more than one icon for your alerts? Consider using CoreUI Icons.

undefined
An example alert with an icon
undefined
An example success alert with an icon
undefined
An example warning alert with an icon
undefined
An example danger alert with an icon
<CAlert color="primary" class="d-flex align-items-center">
  <CIcon icon="cil-info" class="flex-shrink-0 me-2" width="24" height="24" />
  <div>
    An example alert with an icon
  </div>
</CAlert>
<CAlert color="success" class="d-flex align-items-center">
  <CIcon icon="cil-check-circle" class="flex-shrink-0 me-2" width="24" height="24" />
  <div>
    An example success alert with an icon
  </div>
</CAlert>
<CAlert color="warning" class="d-flex align-items-center">
  <CIcon icon="cil-warning" class="flex-shrink-0 me-2" width="24" height="24" />
  <div>
    An example warning alert with an icon
  </div>
</CAlert>
<CAlert color="danger" class="d-flex align-items-center">
  <CIcon icon="cil-burn" class="flex-shrink-0 me-2" width="24" height="24" />
  <div>
    An example danger alert with an icon
  </div>
</CAlert>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

Solid #

Use variant="solid" to change contextual colors to solid.

A simple solid primary alert—check it out!
A simple solid secondary alert—check it out!
A simple solid success alert—check it out!
A simple solid danger alert—check it out!
A simple solid warning alert—check it out!
A simple solid info alert—check it out!
A simple solid light alert—check it out!
A simple solid dark alert—check it out!
<CAlert color="primary" variant="solid">A simple solid primary alert—check it out!</CAlert>
<CAlert color="secondary" variant="solid">A simple solid secondary alert—check it out!</CAlert>
<CAlert color="success" variant="solid">A simple solid success alert—check it out!</CAlert>
<CAlert color="danger" variant="solid">A simple solid danger alert—check it out!</CAlert>
<CAlert color="warning" variant="solid">A simple solid warning alert—check it out!</CAlert>
<CAlert color="info" variant="solid">A simple solid info alert—check it out!</CAlert>
<CAlert color="light" variant="solid" class="text-high-emphasis">A simple solid light alert—check it out!</CAlert>
<CAlert color="dark" variant="solid">A simple solid dark alert—check it out!</CAlert>
1
2
3
4
5
6
7
8

Dismissing #

Alerts can also be easily dismissed. Just add the dismissible prop.

Go right ahead and click that dimiss over there on the right.
<CAlert color="warning" dismissible @close="alert">
  <strong>Go right ahead</strong> and click that dimiss over there on the right.
</CAlert>

<script>
  export default {
    methods: {
      alert () {
        alert("👋 Well, hi there! Thanks for dismissing me.")
      },
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13

Customizing #

CSS variables #

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

--cui-alert-bg: transparent;
--cui-alert-padding-x: #{$alert-padding-x};
--cui-alert-padding-y: #{$alert-padding-y};
--cui-alert-margin-bottom: #{$alert-margin-bottom};
--cui-alert-color: inherit;
--cui-alert-border-color: transparent;
--cui-alert-border: #{$alert-border-width} solid var(--cui-alert-border-color);
--cui-alert-border-radius: #{$alert-border-radius};
1
2
3
4
5
6
7
8

How to use CSS variables #

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

SASS variables #

$alert-padding-y:               $spacer;
$alert-padding-x:               $spacer;
$alert-margin-bottom:           1rem;
$alert-border-radius:           $border-radius;
$alert-link-font-weight:        $font-weight-bold;
$alert-border-width:            $border-width;
$alert-bg-scale:                -80%;
$alert-border-scale:            -70%;
$alert-color-scale:             40%;
$alert-dismissible-padding-r:   $alert-padding-x * 3; // 3x covers width of x plus default padding on either side
1
2
3
4
5
6
7
8
9
10

API #

CAlert #

import { CAlert } from '@coreui/vue'
// or
import CAlert from '@coreui/vue/src/components/alert/CAlert'
1
2
3

Props #

Prop nameDescriptionTypeValuesDefault
colorSets the color context of the component to one of CoreUI’s themed colors.string'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
dismissibleOptionally add a close button to alert and allow it to self dismisss.boolean-false
variantSet the alert variant to a solid.string'solid'-
visibleToggle the visibility of alert component.boolean-true

Events #

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

CAlertHeading #

import { CAlertHeading } from '@coreui/vue'
// or
import CAlertHeading from '@coreui/vue/src/components/alert/CAlertHeading'
1
2
3

Props #

Prop nameDescriptionTypeValuesDefault
componentComponent used for the root node. Either a string to use a HTML element or a component.string-'h4'
On this page
  • Examples
    • Live example
    • Link color
    • Additional content
    • Icons
    • Solid
    • Dismissing
  • Customizing
    • CSS variables
    • SASS variables
  • API
    • CAlert
    • CAlertHeading
  • 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.