Alert
#

Displays a short, important message to attract user attention. If you need to send a notification to users, you can use our Toast component.

When To Use
#

  • When you need to show an important message to users.
  • When you need a static container with some important information which is closable by user actions.

Examples
#

Default
#

The basic usage of the va-alert component.

Open in GitHub

Different styles
#

3 styles are available: color, outlined and border styled alerts.

Open in GitHub

Color
#

Use color property to change the color of the component and text-color to change the textual content color.

Open in GitHub

Border
#

Use the border property to add a strip and the border-color property to change the color of the strip.

Open in GitHub

Dense
#

The dense property reduces paddings on alert.

Open in GitHub

Title
#

The title property allows you to write text over the description area. Use the title slot to customize the title area.

Open in GitHub

Icon
#

The icon property allows you to add an icon in front of the description area. Use the icon slot to customize the icon area.

Open in GitHub

Closeable
#

The closeable property add a close alert area. Also you can pass close-text prop to make close icon as plain text.

Open in GitHub

Center
#

The center property allows you to center title and description areas.

Open in GitHub

Accessibility
#

The component has a alert role. It's communicating an important message, and different from alertdialog role, it doesn't interrupt the user's workflow.

API
#

Props #

NameDescriptionTypesDefault
border

Stripe border for alert. top, right, bottom, left sizes are available

String

""

borderColor

Border color of the alert

String

""

center

Center the title and description of the alert

Boolean

false

closeable

Add a close alert area

Boolean

false

closeIcon

Replace the default close icon with a custom one

String

"close"

closeText

Use text instead of the close icon

String

""

color

Color of the component (theme string or HEX string).

String

"primary"

dense

Reduces alert paddings

Boolean

false

description

The text content of the alert

String

""

icon

Show icon in front of alert content

String

""

modelValue

The value of the v-model bindings.

Boolean

true

outline

Removes background.

Boolean

false

preset

Named preset combination of component props.

String | Array

-

stateful

Add possibility to work with component without setting v-model.

Boolean

true

textColor

Text color (theme string or HEX string).

String

""

title

The text content placed in the title

String

""

Events #

NameDescription

update:modelValue

The event is triggered when the component needs to change the model. Is also used by v-model and must be listed after the v-model

Slots #

NameDescription

close

Alert close area content

default

Content of alert body

icon

Alert icon area content

title

Alert title area content

Methods #

NameDescription

hide

Hides alert (on stateless alert only emits input)

Css Variables #

NameDefault Value
--va-alert-position relative
--va-alert-display flex
--va-alert-align-items center
--va-alert-margin-y 0.25rem
--va-alert-padding-x 0.75rem
--va-alert-padding-y 0.75rem
--va-alert-padding-y-dense 0.25rem
--va-alert-border-width 0
--va-alert-border-radius 4px
--va-alert-box-shadow var(--va-box-shadow)
--va-alert-color transparent
--va-alert-title-font-weight 600
--va-alert-top-border-radius 4px 4px 0 0
--va-alert-right-border-radius 0 4px 4px 0
--va-alert-bottom-border-radius 0 0 4px 4px
--va-alert-left-border-radius 4px 0 0 4px
--va-badge-margin-right 0.5rem
--va-badge-padding-x 0.5rem
--va-badge-padding-y 0.125rem
--va-badge-border-radius 0.5rem
--va-badge-font-size 0.625rem
--va-badge-letter-spacing 0.0625rem
--va-alert-close-padding-x 0.5rem
--va-alert-close-padding-y 0.0625rem
--va-alert-close-font-size 1rem
--va-alert-stripe-border-size var(--va-stripe-border-size)