Skip to content
Latestv1.0.63

Alert ​

YhAlert is used to display important notices and feedback. It supports semantic states, scrolling announcements, auto close, and a custom action area.

Basic States ​

Use type to switch between success, info, warning, and error states.

Basic States

Close and Icons ​

The component is not closable by default. Enable closable to show the close button, and show-icon to display the status icon.

Close and Icons

Scrolling Announcement ​

Enable scrollable for long notice content, then adjust behavior with scroll-speed and pause-on-hover.

Scrolling Announcement

Auto Close ​

Set duration to close the alert automatically. When show-progress is enabled, a progress bar is rendered at the bottom.

Auto Close

Theme Effect ​

effect supports light, dark, outline, and glass.

Theme Effect

Use in Nuxt ​

After installing @yh-ui/nuxt, YhAlert can be used directly in pages. Its initial render does not rely on browser-only APIs, so static content renders correctly during SSR, while auto close and hover pause start on the client after hydration.

Use in Nuxt

API ​

Props ​

NameDescriptionTypeDefault
titleTitle textstring''
descriptionDescription textstring''
typeAlert type'success' | 'info' | 'warning' | 'error''info'
effectVisual style'light' | 'dark' | 'outline' | 'glass''light'
closableWhether to show the close buttonbooleanfalse
close-textCustom close button textstring''
close-iconCustom close icon component or icon namestring | Component''
show-iconWhether to show the status iconbooleanfalse
iconCustom status icon component or icon namestring | Component''
centerWhether the content is centeredbooleanfalse
scrollableWhether to enable scrolling announcement modebooleanfalse
scroll-speedSeconds required to complete one scroll cyclenumber15
pause-on-hoverWhether hovering pauses scrollingbooleantrue
durationAuto close duration in milliseconds. 0 disables auto closenumber0
show-progressWhether to show the auto-close progress barbooleanfalse
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events ​

NameDescriptionParameters
closeTriggered when the close button is clicked(event: MouseEvent)

Slots ​

NameDescription
defaultDescription content
titleTitle content
iconCustom status icon
closeCustom close area
actionCustom action area

Expose ​

This component does not expose public instance methods or properties.

Type Exports ​

NameDescription
YhAlertPropsProps type for YhAlert
YhAlertEmitsEmits type for YhAlert
YhAlertSlotsSlots type for YhAlert
YhAlertTypeAlert type union
YhAlertEffectEffect style union
YhAlertInstanceComponent instance type

Theme Variables ​

YhAlert does not expose a full set of dedicated component-scoped theme variables. The stylesheet currently relies mainly on shared theme tokens. The scrolling announcement mode additionally consumes the variable below, and the component still supports themeOverrides.

VariableDescriptionDefault
--yh-alert-scroll-speedAnimation duration for scrolling announcements15s

Released under the MIT License.