Skip to content

Warn Alert Component ​

Alert component for displaying information that requires attention.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Examples ​

html
<!-- Global usage -->
<hy-warn text="月落乌啼霜满天"></hy-warn>

Theme Configuration ​

  • Use showIcon to set whether to display the icon, which makes the message type more prominent.

Note

In the current version, the icons are built-in Hy icons that vary based on the type parameter and cannot be customized.

html
<template>
    <hy-warn text="风萧萧兮易水寒" show-icon type="success"></hy-warn>
    <hy-warn text="风萧萧兮易水寒" show-icon type="primary"></hy-warn>
    <hy-warn text="风萧萧兮易水寒" show-icon type="error"></hy-warn>
    <hy-warn text="风萧萧兮易水寒" show-icon type="info"></hy-warn>
</template>

Closable Alert ​

  • The closable parameter configures whether the alert can be closed
html
<template>
    <hy-warn text="风萧萧兮易水寒" closable></hy-warn>
</template>

Dark or Light Background ​

html
<template>
    <!-- Light -->
    <hy-warn text="风萧萧兮易水寒" theme="light"></hy-warn>
    <!-- Dark -->
    <hy-warn text="风萧萧兮易水寒" theme="dark"></hy-warn>
</template>

API ​

Warn Props ​

ParameterDescriptionTypeDefault
titleDisplayed textstring-
typeUse preset colorserror|warning|success |primary|infowarning
descriptionAuxiliary text, lighter in color and smaller in font size than title, optionalstring-
closableClose button (defaults to an X icon)booleanfalse
showIconWhether to show the auxiliary icon on the leftbooleanfalse
themeDark or light displaylight | darkdark
centerWhether text is centeredbooleanfalse
fontSizeFont sizestring | number14

Events ​

Event NameDescriptionCallback Parameters
clickTriggered when the component is clicked-
closeTriggered when the component is closed-

CSS Variables ​

Variable NameDescriptionDefault
--hy-warn-title-font-sizeTitle font size14px
--hy-warn-desc-font-sizeDescription font size14px
--hy-warn-close-topClose button top margin11px
--hy-warn-close-rightClose button right margin10px
--hy-warn-radiusContainer border radiusFollows --hy-radius-sm (8rpx)
--hy-warn-text-colorTitle/description color#fff
12:33
battery