Ant Design Svelte

Alert

Messages with status: design, description, actions and smooth closing.

When to use

Alert places a message next to the content of the page: the result of an action, a warning, or an error. It remains visible until removed or closed. Message is suitable for a short temporary response; Result is suitable for the final state of the entire operation.

Status, title and actions

title sets the main message, description - details, action - action nearby. These areas take values ​​and Svelte snippets. type selects success/info/warning/error, variant — outlined/filled.

Problem Opportunity Example
Show short result title, type Key message
Explain the reason and next step description Detailed message
Allow closing object closable Closing
Add action snippet action Actions
Place a banner banner Page Banner
Handle render failure svelte:boundary Error limit

showIcon includes an icon. Icon allows you to set your own; defaults by type can be configured in ConfigProvider.alert. banner changes the standard type/showIcon: if necessary, set them explicitly. The color and icon should complement clear text.

Closing and recovery

closable accepts a boolean or an object with closeIcon, disabled, ARIA attributes, onClose and afterClose. onClose reports a closing request; preventDefault does not override it. afterClose is called after the DOM has been removed, unless the component was unmounted first.

Alert does not have a separate open/bind:open. The closure is stored within the instance. To re-display, create a new instance, such as a keyed block, as in the demo. If a button with focus disappears after deletion, choose a logical place to return in advance.

Compositions and design

React Alert.ErrorBoundary is not exported. Error example uses Alert inside a failed-snippet of a regular svelte:boundary. The moving banner is also the logic of the example: CSS animation with a switch and reduced motion, without an external marquee library.

classNames/styles configure root/icon/section/title/description/actions/close; styles contains CSS strings. For a long title without description, the default alignment can be in the center. For the first line, set semantic styles to match your font and content, rather than a universal calculated offset.

ConfigProvider.alert sets defaults for appearance, closing and icons. Alert design tokens are applied through the theme. In the public package the radius is called borderRadius; the new name containerBorderRadius from the official documentation is not yet its contract.

By default, root has role:alert. For a calm informational message, you can select the appropriate role/aria-live; Don't declare a large immutable block as an urgent event unless necessary.

A non-empty local prefixCls specifies the Alert CSS classes. The empty string and undefined inherit ConfigProvider.prefixCls with the -alert suffix, defaulting to ant-alert. Changing namespace does not reset the closing state, semantic styles and tokens. Example ConfigProvider shows a common prefix along with Collapse and Affix.

Examples

Settings saved

Short message

Normal success message.

Data saved
Update available
Check settings
Failed to save

Message types

success, info, warning and error.

Filled: success
Filled: info
Filled: warning
Filled: error

Filled

Filled design without frame.

Closing message
The button reports the request and completion of the closure.
Message open.

Closing and recovery

disabled, own label and completion of closure.

There are unsaved changes
Open project settings and check member access.
Publication not completed
Please try again after checking the connection.

Details

Text and Snippet descriptions.

Standard badge
Own icon
Icon from provider

Badges

Standard, custom and shared icon.

The service will be unavailable during the update.
The new version is already available.

Banner

type/showIcon default and explicit settings.

Scheduled maintenance: documentation will remain available during the update.

Moving banner

CSS example, switch and reduced motion.

Check settings
The action inside Alert updates the state of the example.

Action in message

Accept and cancel settings.

Long warning about the need to check the project settings before publishing a new version of the documentation.

Alignment of long title

First line via semantic styles.

Section content is available.

Rendering error in Svelte

Applied svelte:boundary with Alert in failed-snippet.

Styles object
Styles function

Semantic DOM

Styles object and function.

Thematic message
Thematic description
Settings are applied in the nested topic.

Tokens and RTL

Radius, padding and icon size.

Notification settings
Check your notification settings before saving.

Notification settings

Original application example with actions and replay.

API

Thirteen ant.design 6.7.0 themes mapped to the public Svelte API. The Loop banner and ErrorBoundary adaptations are separate from the Alert capabilities.

Example themes
ThemeExample or limitation
BasicShort message.
More typessuccess, info, warning and error.
FilledDesign without frame.
Closabledisabled, button label and callbacks.
DescriptionDetails in text and Snippet.
IconStandard, native and provider icon.
BannerWarning strip and explicit type.
Loop BannerMovement - CSS example, with controls and reduced motion.
Smoothly UnmountafterClose reports the completion of closing.
ErrorBoundaryAdaptation via svelte:boundary. React Alert.ErrorBoundary is missing from the package.
Custom actionThe button changes the state of the message.
Custom title alignmentSemantic styles align elements to the first line.
Custom semantic dom stylingObject and callback with props.

Alert

PropertyDescriptionTypeDefault
prefixClsFull local CSS prefix for Alert and its states. The empty string and undefined inherit ConfigProvider.prefixCls; default is ant-alert.stringConfigProvider + -alert
titleText, number, Snippet or array of content.AlertContent—
typeMeaning, background and standard message icon.success | info | warning | errorinfo / warning in banner
variantDesign with or without frame.outlined | filledoutlined
descriptionMessage details.AlertContent—
showIconShow icon.booleanfalse / true in banner
iconYour icon at showIcon.AlertContentby type
actionAction buttons and links.AlertContent—
bannerMessage strip with its own default type/showIcon.booleanfalse
closableButton and lifecycle closure.boolean | AlertClosablefalse
roleFor quiet static examples, you can use status.HTML div rolealert
classNamesSemantic slots classes.AlertSemanticSlots | callback—
stylesCSS lines slots; callback gets allowed props.AlertSemanticSlots | callback—
nativeElementbind:nativeElement is cleared after closing.HTMLDivElement—

AlertClosable

PropertyDescriptionTypeDefault
disabledDisables the close button.booleanfalse
closeIconText or Snippet buttons.AlertContentcross
onCloseClosing request. preventDefault is not a veto.(event: MouseEvent) => void—
afterCloseAfter removing DOM; is canceled when the owner is unmounted.() => void—
aria-labelAvailable button name.stringlocalization

The title is specified via title; Closing callbacks are in closable. ConfigProvider.alert specifies the variant, appearance, close defaults, and type icons.

Semantic DOM

Root has role=alert by default. Actions preserves native buttons and links, close is a real button with an accessible name. title is part of the message, not the title of the page.

Alert
SlotPurpose
rootMessage container.
iconIcon.
sectionText area.
titleMessage title.
descriptionDetails.
actionsActions.
closeClose button.

Registration tokens

The installed package supports borderRadius, defaultPadding, withDescriptionPadding and withDescriptionIconSize. The name containerBorderRadius from the 6.7 documentation is not yet in the public package type.

TokenPurpose
borderRadiusContainer radius in the installed Svelte package.
defaultPaddingShort message indents.
withDescriptionPaddingIndents with description.
withDescriptionIconSizeIcon size with description.
Common tokens of the current topic
TokenMeaning
colorInfoBg#e6f4ff
colorSuccessBg#f6ffed
colorWarningBg#fffbe6
colorErrorBg#fff2f0
colorTextrgba(0,0,0,0.88)
lineHeight1.5714285714285714
fontSize14

FAQ

Why does the information Alert in a dark theme remain light?

In the current native path, set only via mode/primary/compact, info/outlined has light text, but the background remains light. This is observed with both standard and common prefix. The source configuration with cssVar and token.colorPrimary in the tested example uses a dark palette. Setting up the algorithms is described in topic guide; regular prefixCls does not switch the palette.

How to show a closed Alert again?

Create a new instance via key or composition state. It doesn't have open/bind:open.

Which event to use after deletion?

closable.afterClose. onClose is also inside a closable object; the title is set by title.

Is there an Alert.ErrorBoundary?

No. Use svelte:boundary and Alert in failed-snippet, as in the example.

Where does the movement in Loop banner come from?

From the CSS demo. There is a switch, and reduced motion leaves the text motionless.

What is the radius token called?

In the installed public API - borderRadius. ContainerBorderRadius from the new official page is not supported yet.

How to align a long title to the first line?

Set up semantic styles for a specific composition. A standard Alert without description can center the content.