Skip to main content

Alert

Displays important informational messages on the page.

Basic usage​

Basic usage
Info

This is an info message.

Success

This is a success message.

With external state

Closing is internally uncontrolled: clicking the close button unmounts it. Wrap it in a conditional render if you need it reopenable.

import { LhAlert } from '@lh-ui/react'

export default function Demo() {
return (
<LhAlert type="success" title="Success" showIcon closable>
This is a success message.
</LhAlert>
)
}

Alert Props​

PropDescriptionTypeOptionsDefault
typeType'info' | 'success' | 'warning' | 'danger'—'info'
titleTitle (the title row is not rendered when absent)ReactNode——
closableClosableboolean—false
showIconWhether to show the type iconboolean—false
plainPlain style (light outline)boolean—false
closeLabelAccessibility name of the close button (falls back to the language pack's alert.close)string—'Close alert'
sxLayout shorthandSxProps——

Alert events​

EventDescriptionCallback signatureVue equivalent
onCloseFired when the close button is clicked(event: MouseEvent) => void@close
Closing is internally uncontrolled

After the close button is clicked, the Alert unmounts directly (no transition) and fires onClose. To make it reopenable, wrap it in a conditional render driven by external state instead of relying on internal state.

Accessibility live region

When type is warning / danger, it outputs role="alert" (announced immediately); info / success output role="status" (queued announcement), avoiding interrupting the user's current action.

Styles​

import '@lh-ui/react/style/alert'