vael-ui v0.5.7

Feedback

Layout

Message

An inline banner for status text: info, success, warning or error. Use it for a notice that stays in the page.

Install

import { Message } from 'vael-ui'

Playground

Placement, behaviour and animation

Usage
<script setup lang="ts">
import { Message } from 'vael-ui'
</script>

<template>
  <Message variant="info" />
</template>

Props

NameTypeDefaultDescription
titlestringBold heading above the default slot content.
variant'success' | 'warning' | 'info' | 'error' | 'default''default'Color variant; sets the icon and border.
appearance'default' | 'bare''default''bare' drops the border, background and padding, leaving only the icon and colored text. Use it inline, such as for form field validation, instead of as a standalone banner.
closablebooleanfalseRenders the built-in dismiss button.
beforeCloseBeforeClose<MessageCloseReason>Runs before the message closes. Return true to close it, false to keep it open, or a promise of either, like () => confirmAction(…).result. v-model stays true while the promise is pending.
forceMountbooleanfalseKeeps it mounted while closed, toggled with v-show, so its content keeps its state. vael-ui then leaves its motion to you.
motionMessageMotiontrueHow it comes and goes. false shows and hides it at once. An object moves it your way: values for the root part ({ exit: { root: { opacity: 0, x: 24 } } }), { spring }, or enter / leave hooks for your own library. Its space opens as it enters, and closes after it leaves.
showIconbooleantrueShows the leading status icon (or the #icon slot).
role'status' | 'alert'Defaults to 'alert' for 'error' and 'warning', 'status' otherwise.
uiPartial<Record<'root' | 'icon' | 'content' | 'title' | 'description' | 'actions' | 'close', UiPartValue>>Class and style overrides for each part.
openbooleantrueWhether the message is shown.

Events

NameTypeDescription
open-change(value: boolean, details: MessageOpenChangeDetails)Fires before the model flips to false; details.cancel() vetoes the close.
update:open(value: boolean)Fires when open changes (v-model:open).

Slots

NameTypeDescription
defaultanyDescription body, under the optional title.
iconanyReplaces the default StatusIcon.
actionsanyTrailing action row, before the close button.

Exposed

NameTypeDescription
elHTMLElement | nullRoot element (null while closed unless forceMount).
close() => voidCloses the message, running @open-change and beforeClose first.
isClosingbooleantrue while a beforeClose close is pending.
cancelClose() => voidCancels a close pending in beforeClose and keeps the message open.

Motion New

Message coming and going: values or hooks for root.

<Message
  :motion="{ initial: { root: { opacity: 0, y: 4 } } }"
/>
NameTypeDescription
initialexitrootSets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate.
enterleave(parts, context) => animationAnimates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted.
springdurationeasing{ damping, response } | number | stringTimes all of it: a spring, or a duration in ms with an easing. Never both.
falsebooleanTurns its motion off, for an animation of your own on its exposed elements.

Accessibility

KeyAction
EnterSpaceCloses the message from the focused dismiss button.
  • Renders role="alert" for error and warning and role="status" otherwise; the role prop overrides it.
  • The closable button is named “Dismiss”. The status icon is aria-hidden.
  • Closing it from the keyboard moves focus to the next focusable element, so focus doesn’t drop to the page.