Skip to content

Alert

Alert component for displaying important tips or feedback information to users. Features multiple built-in state modes, innovative glassmorphism visual effects, and ultra-smooth marquee announcement functionality.

Display Modes

Alert supports multiple semantic states and visual themes.

Basic Usage

Configurable Interactions

The component is not closable by default. You can enable it via the closable prop. It also supports showing status icons and their positions.

Buttons & Icons

Text Scrolling (Scrollable)

For lengthy announcement content, enable the scrollable prop to achieve a marquee scrolling effect. We use will-change: transform and translate3d hardware acceleration to optimize scrolling smoothness to the extreme.

Scrolling Notification

Auto Close & Timer (Advanced)

YhAlert supports timed closing. When show-progress is enabled, a dynamic countdown progress bar appears at the bottom.

Auto Dismiss Demo

Advanced Features

1. Smart Glassmorphism

Enable via effect="glass". The component will automatically apply backdrop blur and semi-transparent overlays, perfect for modern dashboards with strong visual backgrounds.

Glassmorphism Effect

2. Polymorphic Action Slot

Supports the action slot. You can place interactive buttons like "Retry" or "View Details" inside the alert bar, transforming alerts from one-way notifications into two-way interactions.

Use in Nuxt

YhAlert is fully adapted for Nuxt 3/4. The component supports automatic import, and all animation strategies are optimized for SSR environments.

Use in Nuxt

API

Props

PropDescriptionTypeDefault
titleTitlestring
descriptionDescriptionstring
typeType'success' | 'info' | 'warning' | 'error''info'
effectTheme'light' | 'dark' | 'outline' | 'glass''light'
closableWhether closablebooleanfalse
close-textCustom text for the close buttonstring
close-iconIcon for the close buttonstring | Component
show-iconWhether to show the iconbooleanfalse
centerWhether to center the contentbooleanfalse
scrollableWhether to enable marquee scrollingbooleanfalse
scroll-speedSeconds to complete one scroll cyclenumber15
pause-on-hoverWhether to pause scrolling on hoverbooleantrue
durationAuto-dismiss duration in milliseconds, 0 means nevernumber0
show-progressWhether to show auto-close progress barbooleanfalse

Slots

Slot NameDescription
defaultDescription content
titleTitle content
iconCustom icon
closeCustom close trigger
actionCustom action area (below description)

Events

Event NameDescriptionParameters
closeTriggered when closed(evt: MouseEvent)

Theme Variables

You can deeply customize Alert's visual style through the following CSS variables.

VariableDescriptionDefault
--yh-alert-paddingPadding12px 16px
--yh-alert-border-radiusBorder radius12px
--yh-alert-title-font-sizeTitle font size14px
--yh-alert-description-font-sizeDescription font size13px
--yh-alert-icon-sizeIcon size20px
--yh-alert-scroll-speedScroll speed control (S)15s

Released under the MIT License.