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

Alert

alert

Communicates persistent informational, success, warning, or danger messages.

Usage

Five tone

tone provides neutral / info / success / warning / danger with icon slot.

Information prompt
This is a general information prompt.
Action completed
Profile has been saved.
Planned maintenance
The service will be under maintenance on Sunday.
Unable to connect to the server
Please try again later.
tsx
<>
  <Alert tone="info" icon={<InfoIcon />} title="Information prompt">This is a general information prompt. </Alert>
  <Alert tone="success" icon={<SuccessIcon />} title="Operation successful">Personal information has been saved. </Alert>
  <Alert tone="warning" icon={<WarningIcon />} title="Planned Maintenance">The service will be maintained on Sunday. </Alert>
  <Alert tone="danger" icon={<DangerIcon />} title="Unable to connect to the server">Please try again later. </Alert>
</>

With action button

action slots the operation buttons on the right side, side by side with the text.

Update available
There is a new version of the app, please refresh to get the latest features.
tsx
<Alert tone="info" icon={<InfoIcon />} title="Updates available" action={<Button size="sm">Refresh</Button>}>
  There is a new version of the app, please refresh to get the latest features.
</Alert>

Dismissible

Pass onClose Renders the close button in the upper right corner, blanking is controlled by the caller.

Personal information updated successfully
tsx
<Alert tone="success" icon={<SuccessIcon />} title="Personal information updated successfully" onClose={() => setShow(false)} />

Loading state

icon slot Spinner, expressing an ongoing asynchronous operation.

Processing your request
Synchronizing data, please wait...
tsx
<Alert tone="info" icon={<Spinner size="sm" />} title="Processing your request">
  Synchronizing data, please wait...
</Alert>

Stroke variant

variant="outline" Delimited by a transparent bottom border.

Stroke warning
The transparent bottom is demarcated by the border.
tsx
<Alert variant="outline" tone="warning" icon={<WarningIcon />} title="Stroke Warning">
  The transparent bottom is demarcated by the border.
</Alert>

When to use

Use Alert for persistent contextual feedback within a page or section, such as a validation summary, status explanation, or inline warning. Use Banner for a full-width announcement, Toast for transient imperative feedback, or Notification for a richer notification in a screen corner.

Import

ts
import { Alert, alertVariants } from "@hulianui/ui"

Props

Inherits HTMLAttributes<HTMLDivElement> except title, plus alertVariants:

NameTypeDefaultDescription
tone"neutral"|"brand"|"info"|"success"|"warning"|"danger""info"Semantic tone. brand uses the primary colour; info uses the dedicated info colour (the two stopped being identical in 0.8.0).
variant"soft"|"outline""soft"Soft background or outlined treatment.
closeLabelstring"\u5173\u95ed"Close-button accessible label. The built-in Chinese copy means “Close.”

Events

EventTypeDescription
onClose() => voidWhen provided, renders a close button and reports activation; the consumer controls removal.

Slots

SlotTypeDescription
iconReactNodeOptional caller-provided SVG or emoji; the design system does not bind an icon library.
titleReactNodeOptional title; children provide the description.
actionReactNodeAction beside the close button, such as <Button>Retry</Button>.

Example

tsx
<Alert tone="success" icon={SuccessIcon} title="Saved">Your profile has been updated.</Alert>

<Alert tone="danger" title="Cannot connect" onClose={() => setShown(false)} action={<Button>Retry</Button>}>
  A connection problem occurred. Try again later.
</Alert>

Usage guidelines

  • onClose reports intent but does not hide the alert. The consumer controls rendering; without it, no close button appears.
  • Supply icons yourself as SVG or emoji.
  • The props omit native HTML title so the component's ReactNode title is unambiguous.
  • info and brand are two different colours from 0.8.0 onwards and are no longer interchangeable. info used to be an alias of brand because the library had no info colour and had to borrow the primary one. Now that @hulianui/tokens ships --color-info, brand stays on the primary colour while info moves to a hue 30° away from it. The default Alert (tone="info") therefore changes colour when you upgrade. Pass tone="brand" explicitly to keep the original brand blue. Choose by meaning: brand when the message is about the product or the main action, info when it is purely explanatory.

Related

Banner · Toast · Notification · ServiceMessage · Result · GiftFeed

Playground

Prompt title
This is a prompt message.
<Alert tone="info" variant="soft" icon={<Icon />} title="Prompt title">This is a prompt message.</Alert>
PreviousElementSelectionOverlayFeedbackNextInterceptCard

On this page

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