Ant Design Svelte

App

Response context: Message, Notification and Modal, general settings and independent queues.

When to use

App combines MessageHolder, NotificationHolder and ModalHolder in one application area. Child components receive response APIs through App.useApp() or a separate useApp(). For a local independent queue you can still use createMessage/createNotification/createModal and your own holder.

Getting context

Place the ConfigProvider outside the App and the API consumer as a child component. Basic example consists of Basic.svelte and Actions.svelte: the first defines the scope, the second calls App.useApp() on initialization. The card sources contain both files with signatures; save them separately.

AppInstance contains stable message, notification and modal. They can be obtained during initialization and then called from handlers. Do not call useApp in a handler or in a parent that will only render the App below: it does not yet have access to the child context. Repeated manual holders for the same APIs are not needed.

Response API Details
Short message message.open/info/success/error/warning/loading message
Event details notification.open/info/success/error/warning notification
User decision modal.info/success/error/warning/confirm Modal

Defaults and independent queues

message and notification on the App set defaults. Settings are combined by fields with the nearest App; local undefined also overrides the parent field and returns the default holder. The specific message/notification configuration has higher priority.

Updating settings does not restart timers or delete open entries. duration, pauseOnHover, maxCount and notification.placement apply to subsequent calls. The new maxCount limits the queue on the next addition; existing notifications retain their placement. top/bottom changes the position of the corresponding surface.

App.message accepts list options including stack, getContainer, rtl, transitionName, classNames and styles. With a threshold of two, the third message collapses the list. Hover to see all three entries. Message placement.

In the defaults example, enable the six-second timeout. The next notice uses duration and showProgress from App.notification. Open cards keep their position and timer.

Nested App inherits the settings, but has independent queues and a modal controller. Clearing a nested scope does not delete the parent's responses. Include an App when you really need a separate area; normal child components need the closest API.

Root, theme and life cycle

App renders a div by default. The component prop accepts an HTML tag name, a Svelte component or false. The custom root example passes a heading and HTML attributes to a component. The root renders children, including the holders, and exposes its DOM element with $bindable() and bind:this. The AppRootProps type describes the shared root props. In fragment mode nativeElement is undefined. Changing the root recreates the child DOM and clears the holders. The App instance methods stay available.

ConfigProvider.app specifies the class/style of the wrapper. undefined inherits record, its own object, including {}, replaces it entirely. The provider and instance classes are additive; local style comes last. These rules are different from combining message/notification by fields. A non-empty local prefixCls specifies the App classes, otherwise the base prefix ConfigProvider + app is used. An empty string inherits the provider's fallback.

The topic, locale and direction of responses belong to the ConfigProvider under which the App placed holders. In SSR App does not open dialog/popover and does not start timers. Removing an area closes surfaces, frees the modal, and terminates pending modal handles with false. Don't store the shared AppInstance in the server module between requests; pass the instance-specific API to the desired application handler.

Generic ConfigProvider.prefixCls changes the classes of App and other connected families; their list is given on the ConfigProvider page. message/notification/Modal inherit the common prefix regardless of App.prefixCls. CSS response prefixes show separate message.prefixCls and notification.prefixCls. An empty line returns them to the ConfigProvider.

App uses design tokens from the current theme for its appearance.

Examples

No solution

Responses via App

message, notification and Modal from child App.useApp(). The source contains Basic.svelte and Actions.svelte.

No solution

The new limit is applied the next time you add it. Open notifications save position.

Response settings

New defaults do not restart open records. Two files: Defaults.svelte and Actions.svelte.

External area

No solution

The nested area inherits defaults, but has its own queues.

No solution

Independent areas

The nested App inherits the defaults fields and creates its own queues. Two files: Nested.svelte and Actions.svelte.

Release actions

No solution
no

Changing a tag or fragment recreates the child DOM and clears holders.

Root and fragment

FeedbackSection receives a heading and exposes its section element through bind:nativeElement. Use the checkbox to switch to a fragment.

Typography App and local padding.

No solution

An empty app-record replaces the defaults of the ancestor.

Design App

ConfigProvider.app, local styles, empty record and aliases. Two files: Config.svelte and Actions.svelte.

No solution

App.prefixCls refers to the wrapper. Message and Notification specify the full local prefix in their records; the empty string inherits ConfigProvider. Modal separately inherits the common prefix or receives prefixCls in the confirmation configuration.

CSS prefixes for App responses

Common prefix and separate message/notification settings while maintaining open responses.

API

Purpose, configuration, nesting and fragment are verified with the official App page. The contracts and snippets below belong to the public Svelte API.

ThemeExample or limitation
BasicChild App.useApp receives message, notification and modal.
Hooks configGeneral queue settings and reactive defaults update.
Sequence with ConfigProviderProvider outside the App sets the theme and class/style defaults.
Embedded usage scenariosSettings are inherited by fields; the queues remain independent.
component=falseFragment without root, bind:nativeElement and cleanup when changing mode.
Global sceneAPI is received in a child component. A common queue is not created in the server module.

App

PropertyDescriptionTypeDefault
childrenChild tree with access to the nearest App.Snippet—
componentAn HTML tag, a Svelte component with its own props, or false for a fragment. Changing the root recreates its contents and holders.keyof HTMLElementTagNameMap | Component<Props> | falsediv
messageDefaults message queue; local fields complement parent fields.AppMessageConfigFrom the nearest App
notificationDefaults notifications and surface positions.AppNotificationConfigFrom the nearest App
prefixClsFull root prefix; a non-empty prop takes precedence over a general one. undefined/empty string use the base prefix ConfigProvider + app.stringConfigProvider / ant-app
classExtends the class from ConfigProvider.app.string—
rootClassNameAdditional root class.string—
styleLocal CSS after theme and ConfigProvider.app.style.string—
nativeElementThe root DOM element. A custom root exposes it with $bindable(). Its value is undefined in fragment mode and after unmount.HTMLElement | undefinedundefined

AppMessageConfig

PropertyDescriptionTypeDefault
durationSeconds; 0 disables auto-close of new messages.number3
pauseOnHoverPause the timer when hovering.booleantrue
maxCountThe new limit is applied the next time it is added.numberno limit
prefixClsFull prefix of MessageHolder and its cards. The empty string/undefined inherit ConfigProvider. Does not change the queue or timers.stringConfigProvider.prefixCls + "-message"
topOffset from the top of the viewport. Numbers are in pixels.number | string8
rtlSets the text direction for this list.booleanConfigProvider.direction
getContainerReturns the DOM element for the list. Its position is relative to the viewport.() => HTMLElement | null | undefined—
stackCollapses the list above the threshold. The default threshold is three messages.boolean | { threshold?: number }false
transitionNameCSS transition name. An empty string disables animation.string—
classNamesCSS classes for message parts, as an object or a function of props.MessageSemantic—
stylesInline CSS for individual parts, as an object or a function of props.MessageSemantic—

AppNotificationConfig

PropertyDescriptionTypeDefault
placementGeneral position of the instance.NotificationPlacementtopRight
durationTotal duration.number | false4.5
pauseOnHoverGeneral timer pause.booleantrue
maxCountGeneral limit for all placements.numberno limit
showProgressShows the time remaining before dismissal.booleanfalse
prefixClsFull CSS prefix for the list and its cards.stringConfigProvider.prefixCls + "-notification"
topTop surface offset.number24
bottomBottom surface offset.number24
stackCollapse threshold for each placement. Use false to keep the list expanded.boolean | { threshold?: number }{ threshold: 3 }
rtlText direction. The placement option selects the side of the screen.booleanConfigProvider.direction
getContainerSelects the DOM node where the notification list appears.() => HTMLElement | ShadowRoot | null | undefined—
closeIconCustom close icon for all cards.NotificationContentConfigProvider.notification.closeIcon
classNamesCSS classes for this instance’s list and cards.NotificationSemantic—
stylesStyles for this instance’s list and cards.NotificationSemantic—
onAllRemovedRuns after the last card leaves the DOM.() => void—

App.useApp() and useApp()

Called when a child component is initialized. AppInstance contains stable message, notification and modal. Individual holders are already connected to the App; a second holder of the same API is not needed.

Recording parameters are described on pages Message, Notification and Modal. ConfigProvider.app only accepts class/style; local style takes precedence.

Semantic DOM

By default, App creates a div with class ant-app, marker ant-app-css-var and theme typography. HTML attributes and nativeElement refer to this root. This is a description of the actual markup: classNames/styles and named semantic slots are not published.

component=false displays children and holders without root; class/style/attrs and nativeElement wrappers are not applied. The location of surfaces and their accessibility belong to MessageHolder, NotificationHolder and native Modal. The App does not create a general focus trap.

Registration tokens

There are no proprietary App component tokens. General aliases can be refined via theme.components.App: the design example changes the root typography while preserving the Button's own tokens. Without the component=false root, these App styles have nowhere to apply; decorate the outer container.

TokenCurrent topic value
colorTextrgba(0,0,0,0.88)
fontSize14
lineHeight1.5714285714285714
fontFamily-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'

FAQ

Why does useApp report that the App is missing?

The call must occur when a child component under App is initialized. The call in the same parent that draws the App below does not receive its context. Place the consumer in a child component, as in the Actions.svelte source code.

Are MessageHolder and ModalHolder needed next to the App?

App has already connected all three holders. Add a separate holder only for a separately created instance of createMessage/createNotification/createModal.

Why didn't the new maxCount delete old messages immediately?

Defaults change the following calls. The queue is shortened with the next addition; open timers are not restarted. For explicit cleanup, call message.destroy() or notification.destroy(). modal does not have such a general destroyAll: destroy a specific handle.

Why did component=false change the design and reset the child draft?

The App root is gone, so its class/style/attrs and typography aliases don't apply. Changing the mode recreates children/holders. Set the desired design to the outer container and store the saved model above this border.

Is it possible to use the API outside of a child handler?

Get the API when initializing a specific area and pass it explicitly to the desired function. Don't call useApp outside of lifecycle and don't create a server-side global queue for different users.