Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Overlays

  • Dialog
  • Modal
  • AlertDialog
  • Drawer
  • Popover
  • Tooltip
  • HoverCard
  • Glimpse
  • HeroVideoDialog
  • ElementSelectionOverlay

Messages

  • Alert
  • InterceptCard
  • Callout
  • Banner
  • Toast
  • Notification
  • ServiceMessage
  • Result
  • GiftFeed
  • FloatingReactions
  • Popconfirm

Loading and Progress

  • Spin
  • Spinner
  • Progress

Guidance

  • Tour

Notification

notification

Stacks positioned notification cards with icons, content, actions, and an imperative API.

Usage

Five types

notification.success / error / info / warning / open, derive the left color bar and default icon.

tsx
notification.success({ title: "Save successfully", description: "Changes have been synchronized." });
notification.error({ title: "Upload failed", description: "The file is too large, please compress and try again." });
notification.info({ title: "System Notification", description: "The maintenance window will start tonight." });
notification.warning({ title: "Insufficient space", description: "The remaining capacity is less than 10%." });

With operation button + permanent

btn slot operation button, it will not close automatically when duration=0.

tsx
notification.open({
  title: "Received a friend request",
  description: "From Design Department·Xiao Lian",
  duration: 0,
  btn: <Button size="sm">View</Button>,
});

Four corner positions

placement Specifies the pop-up location: topRight / topLeft / bottomRight / bottomLeft.

tsx
notification.info({ title: "Prompt", description: "Bounce at the specified corner", placement: "bottomLeft" });

When to use

Use Notification for a substantial corner message with a title, description, and optional action, such as a friend request or a retryable upload failure. It carries more information than Toast, can persist, and supports actions. Use Toast for one short automatically dismissed line. Calls are imperative, but NotificationProvider must be mounted once by the layout.

Import

ts
import { notification, NotificationProvider, hulianNotificationManager } from "@hulianui/ui"

Props

notification.success/error/info/warning/open(options) accepts NotificationOptions:

NameTypeDefaultDescription
type"open"|"success"|"error"|"info"|"warning"-Implied by the method. open is neutral without a default icon; other types derive the accent and icon from Alert-aligned tokens.
durationnumber4500Automatic dismissal in milliseconds. 0 remains open.
placement"topRight"|"topLeft"|"bottomRight"|"bottomLeft""topRight"Screen corner.

The returned NotificationInstance provides destroy(): void for immediate programmatic dismissal.

The notification close control uses the built-in Chinese aria-label "\u5173\u95ed", meaning “Close.”

Events

EventTypeDescription
onClose() => voidCalled once after automatic, manual, or programmatic dismissal.

Slots

SlotTypeDescription
titleReactNodeBold primary line.
descriptionReactNodeMuted secondary line.
iconReactNodeCustom icon replacing the type-derived default.
btnReactNodeAction area rendered below the description.

Example

tsx
// Automatically closes after 4.5 seconds
notification.success({ title: "Saved", description: "Changes are synchronized." })

// Persistent notification with an action
notification.open({
  title: "New friend request",
  description: "From the Design team",
  duration: 0,
  btn: <Button size="sm" onClick={() => {}}>View</Button>,
})

Usage guidelines

  • Mount NotificationProvider once in the layout, following Toast and Modal. Do not mount it at every call site or showcase.
  • Only duration: 0 persists; omission closes after 4500 ms. Set zero explicitly for information that must be acknowledged.
  • An imperative notification is fire-and-forget. onClose runs once but should not depend on stale captured application state; see [[fire-and-forget-side-effect-notification]].

Related

Alert · Banner · Toast · ServiceMessage · Result · GiftFeed

Playground

notification.success({
  title: "Action completed",
  description: "The data has been successfully synchronized to the cloud.",
  placement: "topRight",
  duration: 4500,
})
PreviousToastFeedbackNextServiceMessage

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related
  • Playground