Skip to main content

Message

Lightweight global overlay feedback: operation success / failure, network status, etc. Mounted in a singleton container, multiple messages stack top to bottom.

Basic usage​

Basic usage
import { message } from '@lh-ui/react'
import '@lh-ui/react/style/message'

message.success('Saved successfully')

message methods​

MethodDescriptionReturn value
info / success / warning / error / dangerShow a message{ close }
loadingShow a loading message (does not auto-close by default){ close }
destroyAllClose all messages and unmount the containervoid

The returned handle is used for active closing:

const handle = message.loading('Uploading…', { duration: 0 })
// ...
handle.close()

LhMessageOptions​

PropDescriptionTypeDefault
durationAuto-close duration in ms; 0 never auto-closes (the loading semantic defaults to 0)number3000
showCloseWhether to show the close buttonbooleanfalse
offsetOffset from the top of the viewport, in pxnumber20
closeLabelaria-label of the close buttonstringLocale pack (en-US: Close message)
onCloseCallback on close() => void—
sxShorthand layout propsSxProps—
Event mapping from the Vue version

message.success('x') corresponds to plus's LhMessage.success('x'); the handle's close() corresponds to plus's LhMessage.close(id). The React side manages via the return value instead of global ids.

Accessibility

Success / info are role="status" (queued announcement), error / warning are role="alert" (immediate announcement) — the same paradigm as Alert and Notification.

Styles​

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