Skip to content
API 风格:

Alert ​

Static page-level alerts (not imperative — see Message for that). Semantics drive the live-region role: warning/danger use role="alert" for immediate announcement, info/success use role="status" for polite announcement.

Basic Usage ​

Four Types

A neutral note.

Operation completed.

vue
<script setup lang="ts">
</script>

<template>
  <!-- Neutral -->
  <LhAlert>A neutral note.</LhAlert>
  <!-- success -->
  <LhAlert type="success">Operation completed.</LhAlert>
  <!-- warning -->
  <LhAlert type="warning">Disk space is running low.</LhAlert>
  <!-- danger -->
  <LhAlert type="danger">Network connection lost.</LhAlert>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- Neutral -->
  <LhAlert>A neutral note.</LhAlert>
  <!-- success -->
  <LhAlert type="success">Operation completed.</LhAlert>
  <!-- warning -->
  <LhAlert type="warning">Disk space is running low.</LhAlert>
  <!-- danger -->
  <LhAlert type="danger">Network connection lost.</LhAlert>
</template>

Icon and Title ​

Icon and Title
Saved

The document is synced to the cloud.

vue
<script setup lang="ts">
</script>

<template>
  <!-- Saved -->
  <LhAlert type="success" show-icon title="Saved">The document is synced to the cloud.</LhAlert>
  <!-- Delete failed -->
  <LhAlert type="danger" show-icon title="Delete failed">The item is being edited by another collaborator.</LhAlert>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- Saved -->
  <LhAlert type="success" show-icon title="Saved">The document is synced to the cloud.</LhAlert>
  <!-- Delete failed -->
  <LhAlert type="danger" show-icon title="Delete failed">The item is being edited by another collaborator.</LhAlert>
</template>

Closable ​

Closable

Close me with the button on the right.

vue
<script setup lang="ts">
</script>

<template>
  <!-- Closable -->
  <LhAlert closable>Close me with the button on the right.</LhAlert>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- Closable -->
  <LhAlert closable>Close me with the button on the right.</LhAlert>
</template>

Plain Style ​

Plain
vue
<script setup lang="ts">
</script>

<template>
  <!-- warning plain -->
  <LhAlert type="warning" plain show-icon>Light outlined style.</LhAlert>
  <!-- danger plain -->
  <LhAlert type="danger" plain show-icon>Suitable on light backgrounds.</LhAlert>
</template>
vue
<script>
export default {}
</script>

<template>
  <!-- warning plain -->
  <LhAlert type="warning" plain show-icon>Light outlined style.</LhAlert>
  <!-- danger plain -->
  <LhAlert type="danger" plain show-icon>Suitable on light backgrounds.</LhAlert>
</template>

API ​

Props ​

PropDescriptionTypeDefault
typeSemantic type"info" | "success" | "warning" | "danger"'info'
titleTitle (or use the title slot)string—
closableShow the close buttonbooleanfalse
showIconShow the semantic iconbooleanfalse
plainLight outlined stylebooleanfalse
closeLabelAccessible name of the close button (falls back to the alert.close locale message)string—
sxsx quick-layout propertiesLhSxProps—

Events ​

EventDescriptionCallback
closeFired after the close button is clicked—

Slots ​

SlotDescription
titleCustom title
defaultDescription content

Accessibility ​

  • warning/danger → role="alert" (immediate); info/success → role="status" (polite)
  • The close button is a real <button> with an aria-label from the alert.close locale message and a :focus-visible ring
  • Tinted backgrounds derive from semantic colors via color-mix(), following theme and dark mode automatically

Type Definitions ​

The TypeScript type structures exported by this component (auto-extracted from packages/components/alert/src/types.ts and @lh-ui/share/core/* sources; click each entry to expand; see the Props table above for attribute descriptions):

LhAlertProps
ts
export interface LhAlertProps {
  type?: LhAlertType
  title?: string
  closable?: boolean
  showIcon?: boolean
  plain?: boolean
  closeLabel?: string
  sx?: LhSxProps
}
LhAlertType (from @lh-ui/share/core/alert)
ts
export type LhAlertType = 'info' | 'success' | 'warning' | 'danger'

Beauty of tradition, foundation of code