Skip to main content

Notification

Heavier feedback than Message: carries a title / body / type icon, pops from the four corners, and suits longer system notifications.

Basic usage​

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

notification.success({ title: 'Saved successfully', content: 'The work has been published to the gallery.' })

// String shorthand: only the title line is rendered
notification.info('System notification')

notification methods​

MethodDescriptionReturn value
info / success / warning / error / dangerShow a notification{ close }
closeClose the given notification (plays the leave animation first)void
closeAllClose all notifications and unmount the containervoid
const handle = notification.warning({ title: 'Insufficient storage space' })
handle.close()

LhNotificationOptions​

PropDescriptionTypeDefault
titleTitle (falls back to content when omitted)string—
contentBody (when equal to title, only the title line is rendered)string—
durationAuto-close duration in ms; 0 never auto-closesnumber4500
positionPop position'top-right' | 'top-left' | 'bottom-right' | 'bottom-left''top-right'
showCloseWhether to show the close buttonbooleantrue
closeLabelaria-label of the close buttonstringLocale pack (en-US: Close notification)
onClickClick callback (the card becomes clickable once passed)() => void—
onCloseCallback on close() => void—
sxShorthand layout propsSxProps—
Leave animation

React has no transition-group, so each entry manages its own exit: on close it plays lh-notification-slide-leave-* (280ms) first, then removes the record. The FLIP repositioning animation is not implemented: sibling cards jump instantly when entries are added or removed, and the stacking gap is handled by the container's flex gap.

Accessibility

warning / danger are role="alert" (immediate announcement), info / success are role="status" (queued announcement); the container is role="region" + aria-live="polite".

Styles​

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