Skip to content

Alert ​

Displays a callout for user attention.

Usage ​

Approximate web preview — the HarmonyOS rendering is the reference.

Status variants ​

success | warning | info (+ destructive), plain or soft.

Approximate web preview — the HarmonyOS rendering is the reference.

Actions, dismissible, compact ​

A dismissed alert hides itself with the alert motion and emits onDismiss.

Approximate web preview — the HarmonyOS rendering is the reference.

API ​

Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.

SAlert ​

shadcn-vue Alert: relative w-full rounded-lg border px-4 py-3 text-sm grid grid-cols-[16px_1fr] gap-x-3 gap-y-0.5 items-start, bg-card. The destructive variant tints title / icon with text-destructive and the description with text-destructive/90.

heading / description are shortcuts for a title / description without a slot.

Variants: default | destructive | success | warning | info (title and icon take the tone colour). Extras: soft (tinted background and border), compact (tighter padding, centred row), actionLabel + onAction (trailing outline button), dismissible (trailing ×; the alert hides itself and emits onDismiss).

PropTypeDefaultDescription
variantAlertVariant
AlertVariant = 'default' | 'destructive' | 'success' | 'warning' | 'info'
'default'
iconstring | undefinedundefinedlucide icon name shown in the leading column.
headingResourceStr | undefinedundefined
descriptionResourceStr | undefinedundefined
softbooleanfalseTinted background and border in the variant colour.
compactbooleanfalseTighter padding (px-3 py-2), items centred.
actionLabelResourceStr | undefinedundefinedText of a trailing action button.
dismissiblebooleanfalseTrailing × button; the alert hides itself (motion key 'alert') and emits onDismiss.
modifierAttributeModifier<RowAttribute>new SparkNoopModifier<RowAttribute>()
tokensAlertTokens{}Per-instance token overrides (instance → theme --alert-* → recipe), see {@link AlertTokens}.
EventTypeDefaultDescription
onAction() => void() => { }
onDismiss() => void() => { }

Slots: children (trailing closure)

SAlertTitle ​

col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight.

PropTypeDefaultDescription
textResourceStr''

SAlertDescription ​

text-muted-foreground col-start-2 text-sm [&_p]:leading-relaxed (destructive: text-destructive/90).

PropTypeDefaultDescription
textResourceStr | undefinedundefined

Slots: children (trailing closure)

MIT Licensed