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
Responses via App
message, notification and Modal from child App.useApp(). The source contains Basic.svelte and Actions.svelte.
Basic.svelte<script lang="ts"> import { App, ConfigProvider } from '@woodger/antd'; import Actions from './Actions.svelte'; </script> <ConfigProvider> <App message={({ top: 180 })} notification={{ placement: 'bottomRight' }}> <Actions scope={("Main")} /> </App> </ConfigProvider>Actions.svelte<script lang="ts"> import { App, Button } from '@woodger/antd'; let { scope = 'App' }: { scope?: string } = $props(); const api = App.useApp(); let messages = 0; let notifications = 0; let result = $state(("No solution")); async function confirm() { const accepted = await api.modal.confirm(({ title: `Confirmation (${scope})`, content: "Window and responses belong to the nearest App." })); result = accepted ? ("Confirmed") : ("Canceled"); } function clear() { api.message.destroy(); api.notification.destroy(); } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } .actions :global(.ant-btn) { max-width: 100%; height: auto; white-space: normal; } output { display: block; margin-top: 12px; overflow-wrap: anywhere; } </style> <div class="actions"> <Button onclick={() => api.message.info((`${scope}: message ${++messages}`))} >{("\n Message (")}{(scope)}) </Button> <Button onclick={() => api.notification.info(({ title: `${scope}: notice ${++notifications}`, description: "API from App.useApp()" }))}>{("Notice (")}{(scope)})</Button> <Button onclick={confirm}>{("Confirmation (")}{(scope)})</Button> <Button onclick={clear}>{("Clear (")}{(scope)})</Button> </div> <output aria-label={("Solution App (" + String((scope)) + ")")}>{result}</output>
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.
Defaults.svelte<script lang="ts"> import { App, Checkbox, ConfigProvider } from '@woodger/antd'; import Actions from './Actions.svelte'; let single = $state(false); let bottom = $state(true); let timed = $state(false); </script> <style> .example { display: grid; gap: 16px; } .controls { display: flex; flex-wrap: wrap; gap: 12px; } p { margin: 0; } </style> <div class="example"> <div class="controls"> <Checkbox bind:checked={single}>{("Message limit: one")}</Checkbox> <Checkbox bind:checked={bottom}>{("Notifications below")}</Checkbox> <Checkbox bind:checked={timed}> {("Close notices after 6 seconds")} </Checkbox> </div> <ConfigProvider> <App message={{ maxCount: single ? 1 : 3, duration: 0, top: 180, stack: { threshold: 2 } }} notification={{ placement: bottom ? 'bottomRight' : 'topRight', duration: timed ? 6 : 0, showProgress: timed, top: 180 }}> <Actions scope={("Settings")} /> </App> </ConfigProvider> <p>{("The new limit is applied the next time you add it. Open notifications save position.")}</p> </div>Actions.svelte<script lang="ts"> import { App, Button } from '@woodger/antd'; let { scope = 'App' }: { scope?: string } = $props(); const api = App.useApp(); let messages = 0; let notifications = 0; let result = $state(("No solution")); async function confirm() { const accepted = await api.modal.confirm(({ title: `Confirmation (${scope})`, content: "Window and responses belong to the nearest App." })); result = accepted ? ("Confirmed") : ("Canceled"); } function clear() { api.message.destroy(); api.notification.destroy(); } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } .actions :global(.ant-btn) { max-width: 100%; height: auto; white-space: normal; } output { display: block; margin-top: 12px; overflow-wrap: anywhere; } </style> <div class="actions"> <Button onclick={() => api.message.info((`${scope}: message ${++messages}`))} >{("\n Message (")}{(scope)}) </Button> <Button onclick={() => api.notification.info(({ title: `${scope}: notice ${++notifications}`, description: "API from App.useApp()" }))}>{("Notice (")}{(scope)})</Button> <Button onclick={confirm}>{("Confirmation (")}{(scope)})</Button> <Button onclick={clear}>{("Clear (")}{(scope)})</Button> </div> <output aria-label={("Solution App (" + String((scope)) + ")")}>{result}</output>
External area
The nested area inherits defaults, but has its own queues.
Independent areas
The nested App inherits the defaults fields and creates its own queues. Two files: Nested.svelte and Actions.svelte.
Nested.svelte<script lang="ts"> import { App, ConfigProvider } from '@woodger/antd'; import Actions from './Actions.svelte'; </script> <style> .nested { margin-top: 20px; padding: 16px; border: 1px solid var(--ant-color-border-secondary); border-radius: 8px; } p { margin: 0 0 12px; } </style> <ConfigProvider> <App message={({ duration: 0, maxCount: 2, top: 180 })} notification={{ duration: 0, placement: 'bottomLeft' }}> <p>{("External area")}</p> <Actions scope={("External")} /> <div class="nested"> <App message={({ top: 240 })} notification={{ placement: 'bottomRight' }}> <p>{("The nested area inherits defaults, but has its own queues.")}</p> <Actions scope={("Nested")} /> </App> </div> </App> </ConfigProvider>Actions.svelte<script lang="ts"> import { App, Button } from '@woodger/antd'; let { scope = 'App' }: { scope?: string } = $props(); const api = App.useApp(); let messages = 0; let notifications = 0; let result = $state(("No solution")); async function confirm() { const accepted = await api.modal.confirm(({ title: `Confirmation (${scope})`, content: "Window and responses belong to the nearest App." })); result = accepted ? ("Confirmed") : ("Canceled"); } function clear() { api.message.destroy(); api.notification.destroy(); } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } .actions :global(.ant-btn) { max-width: 100%; height: auto; white-space: normal; } output { display: block; margin-top: 12px; overflow-wrap: anywhere; } </style> <div class="actions"> <Button onclick={() => api.message.info((`${scope}: message ${++messages}`))} >{("\n Message (")}{(scope)}) </Button> <Button onclick={() => api.notification.info(({ title: `${scope}: notice ${++notifications}`, description: "API from App.useApp()" }))}>{("Notice (")}{(scope)})</Button> <Button onclick={confirm}>{("Confirmation (")}{(scope)})</Button> <Button onclick={clear}>{("Clear (")}{(scope)})</Button> </div> <output aria-label={("Solution App (" + String((scope)) + ")")}>{result}</output>
Release actions
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.
Root.svelte<script lang="ts"> import { App, Checkbox, ConfigProvider } from '@woodger/antd'; import Actions from './Actions.svelte'; import FeedbackSection from './FeedbackSection.svelte'; let fragment = $state(false); let nativeElement = $state<HTMLElement>(); </script> <style> .example { display: grid; gap: 16px; } p { margin: 0; } </style> <div class="example"> <Checkbox bind:checked={fragment}>{("Without App wrapper")}</Checkbox> <ConfigProvider> <App component={fragment ? false : FeedbackSection} heading={("Release actions")} prefixCls="woodger-app" aria-label={("App Area")} bind:nativeElement message={({ duration: 0, top: 180 })} style=" padding: 16px; border: 1px dashed currentColor; "> <Actions scope={("Root")} /> </App> </ConfigProvider> <output aria-label={("Root App")}>{(nativeElement?.tagName.toLowerCase() ?? "no")}</output> <p>{("Changing a tag or fragment recreates the child DOM and clears holders.")}</p> </div>FeedbackSection.svelte<script lang="ts"> import type { AppRootProps } from '@woodger/antd'; let { heading, children, nativeElement = $bindable(), ...attributes }: AppRootProps & { heading: string } = $props(); </script> <section {...attributes} bind:this={nativeElement}> <h3>{heading}</h3> {@render children?.()} </section>Actions.svelte<script lang="ts"> import { App, Button } from '@woodger/antd'; let { scope = 'App' }: { scope?: string } = $props(); const api = App.useApp(); let messages = 0; let notifications = 0; let result = $state(("No solution")); async function confirm() { const accepted = await api.modal.confirm(({ title: `Confirmation (${scope})`, content: "Window and responses belong to the nearest App." })); result = accepted ? ("Confirmed") : ("Canceled"); } function clear() { api.message.destroy(); api.notification.destroy(); } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } .actions :global(.ant-btn) { max-width: 100%; height: auto; white-space: normal; } output { display: block; margin-top: 12px; overflow-wrap: anywhere; } </style> <div class="actions"> <Button onclick={() => api.message.info((`${scope}: message ${++messages}`))} >{("\n Message (")}{(scope)}) </Button> <Button onclick={() => api.notification.info(({ title: `${scope}: notice ${++notifications}`, description: "API from App.useApp()" }))}>{("Notice (")}{(scope)})</Button> <Button onclick={confirm}>{("Confirmation (")}{(scope)})</Button> <Button onclick={clear}>{("Clear (")}{(scope)})</Button> </div> <output aria-label={("Solution App (" + String((scope)) + ")")}>{result}</output>
Typography App and local padding.
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.
Config.svelte<script lang="ts"> import { App, ConfigProvider } from '@woodger/antd'; import Actions from './Actions.svelte'; </script> <style> .example { display: grid; gap: 16px; } p { margin: 0 0 12px; } </style> <ConfigProvider app={{ class: 'app-defaults', style: ` padding: 16px; border-radius: 8px; ` }} theme={{ components: { App: { colorText: '#237804', fontSize: 16, lineHeight: 1.8 } } }}> <div class="example"> <App class="app-local" style="padding: 8px" aria-label={("App with defaults")} message={({ top: 180 })}> <p>{("Typography App and local padding.")}</p> <Actions scope={("Design")} /> </App> <ConfigProvider app={{}}> <App aria-label={("App without defaults")}> <p>{("An empty app-record replaces the defaults of the ancestor.")}</p> </App> </ConfigProvider> </div> </ConfigProvider>Actions.svelte<script lang="ts"> import { App, Button } from '@woodger/antd'; let { scope = 'App' }: { scope?: string } = $props(); const api = App.useApp(); let messages = 0; let notifications = 0; let result = $state(("No solution")); async function confirm() { const accepted = await api.modal.confirm(({ title: `Confirmation (${scope})`, content: "Window and responses belong to the nearest App." })); result = accepted ? ("Confirmed") : ("Canceled"); } function clear() { api.message.destroy(); api.notification.destroy(); } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } .actions :global(.ant-btn) { max-width: 100%; height: auto; white-space: normal; } output { display: block; margin-top: 12px; overflow-wrap: anywhere; } </style> <div class="actions"> <Button onclick={() => api.message.info((`${scope}: message ${++messages}`))} >{("\n Message (")}{(scope)}) </Button> <Button onclick={() => api.notification.info(({ title: `${scope}: notice ${++notifications}`, description: "API from App.useApp()" }))}>{("Notice (")}{(scope)})</Button> <Button onclick={confirm}>{("Confirmation (")}{(scope)})</Button> <Button onclick={clear}>{("Clear (")}{(scope)})</Button> </div> <output aria-label={("Solution App (" + String((scope)) + ")")}>{result}</output>
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.
Prefix.svelte<script lang="ts"> import { App, Checkbox, ConfigProvider } from '@woodger/antd'; import Actions from './Actions.svelte'; let custom = $state(true); let local = $state(true); </script> <style> .example { display: grid; gap: 16px; min-width: 0; } .controls { display: flex; flex-wrap: wrap; gap: 12px; } p { margin: 0; } </style> <div class="example"> <div class="controls"> <Checkbox bind:checked={custom}>{("General prefix App suite")}</Checkbox> <Checkbox bind:checked={local}>{("Local App response prefixes")}</Checkbox> </div> <ConfigProvider prefixCls={custom ? 'suite' : 'ant'} theme={{ cssVar: { prefix: 'app-prefix-theme' } }}> <App prefixCls="project-app" message={({ prefixCls: local ? 'project-message' : '', duration: 0, top: 240 })} notification={{ prefixCls: local ? 'project-notification' : '', duration: 0, top: 240 }}> <Actions scope={("Prefixes")} /> </App> </ConfigProvider> <p> {("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.")} </p> </div>Actions.svelte<script lang="ts"> import { App, Button } from '@woodger/antd'; let { scope = 'App' }: { scope?: string } = $props(); const api = App.useApp(); let messages = 0; let notifications = 0; let result = $state(("No solution")); async function confirm() { const accepted = await api.modal.confirm(({ title: `Confirmation (${scope})`, content: "Window and responses belong to the nearest App." })); result = accepted ? ("Confirmed") : ("Canceled"); } function clear() { api.message.destroy(); api.notification.destroy(); } </script> <style> .actions { display: flex; flex-wrap: wrap; gap: 8px; } .actions :global(.ant-btn) { max-width: 100%; height: auto; white-space: normal; } output { display: block; margin-top: 12px; overflow-wrap: anywhere; } </style> <div class="actions"> <Button onclick={() => api.message.info((`${scope}: message ${++messages}`))} >{("\n Message (")}{(scope)}) </Button> <Button onclick={() => api.notification.info(({ title: `${scope}: notice ${++notifications}`, description: "API from App.useApp()" }))}>{("Notice (")}{(scope)})</Button> <Button onclick={confirm}>{("Confirmation (")}{(scope)})</Button> <Button onclick={clear}>{("Clear (")}{(scope)})</Button> </div> <output aria-label={("Solution App (" + String((scope)) + ")")}>{result}</output>
API
Purpose, configuration, nesting and fragment are verified with the official App page. The contracts and snippets below belong to the public Svelte API.
| Theme | Example or limitation |
|---|---|
| Basic | Child App.useApp receives message, notification and modal. |
| Hooks config | General queue settings and reactive defaults update. |
| Sequence with ConfigProvider | Provider outside the App sets the theme and class/style defaults. |
| Embedded usage scenarios | Settings are inherited by fields; the queues remain independent. |
| component=false | Fragment without root, bind:nativeElement and cleanup when changing mode. |
| Global scene | API is received in a child component. A common queue is not created in the server module. |
App
| Property | Description | Type | Default |
|---|---|---|---|
children | Child tree with access to the nearest App. | Snippet | — |
component | An 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> | false | div |
message | Defaults message queue; local fields complement parent fields. | AppMessageConfig | From the nearest App |
notification | Defaults notifications and surface positions. | AppNotificationConfig | From the nearest App |
prefixCls | Full root prefix; a non-empty prop takes precedence over a general one. undefined/empty string use the base prefix ConfigProvider + app. | string | ConfigProvider / ant-app |
class | Extends the class from ConfigProvider.app. | string | — |
rootClassName | Additional root class. | string | — |
style | Local CSS after theme and ConfigProvider.app.style. | string | — |
nativeElement | The root DOM element. A custom root exposes it with $bindable(). Its value is undefined in fragment mode and after unmount. | HTMLElement | undefined | undefined |
AppMessageConfig
| Property | Description | Type | Default |
|---|---|---|---|
duration | Seconds; 0 disables auto-close of new messages. | number | 3 |
pauseOnHover | Pause the timer when hovering. | boolean | true |
maxCount | The new limit is applied the next time it is added. | number | no limit |
prefixCls | Full prefix of MessageHolder and its cards. The empty string/undefined inherit ConfigProvider. Does not change the queue or timers. | string | ConfigProvider.prefixCls + "-message" |
top | Offset from the top of the viewport. Numbers are in pixels. | number | string | 8 |
rtl | Sets the text direction for this list. | boolean | ConfigProvider.direction |
getContainer | Returns the DOM element for the list. Its position is relative to the viewport. | () => HTMLElement | null | undefined | — |
stack | Collapses the list above the threshold. The default threshold is three messages. | boolean | { threshold?: number } | false |
transitionName | CSS transition name. An empty string disables animation. | string | — |
classNames | CSS classes for message parts, as an object or a function of props. | MessageSemantic | — |
styles | Inline CSS for individual parts, as an object or a function of props. | MessageSemantic | — |
AppNotificationConfig
| Property | Description | Type | Default |
|---|---|---|---|
placement | General position of the instance. | NotificationPlacement | topRight |
duration | Total duration. | number | false | 4.5 |
pauseOnHover | General timer pause. | boolean | true |
maxCount | General limit for all placements. | number | no limit |
showProgress | Shows the time remaining before dismissal. | boolean | false |
prefixCls | Full CSS prefix for the list and its cards. | string | ConfigProvider.prefixCls + "-notification" |
top | Top surface offset. | number | 24 |
bottom | Bottom surface offset. | number | 24 |
stack | Collapse threshold for each placement. Use false to keep the list expanded. | boolean | { threshold?: number } | { threshold: 3 } |
rtl | Text direction. The placement option selects the side of the screen. | boolean | ConfigProvider.direction |
getContainer | Selects the DOM node where the notification list appears. | () => HTMLElement | ShadowRoot | null | undefined | — |
closeIcon | Custom close icon for all cards. | NotificationContent | ConfigProvider.notification.closeIcon |
classNames | CSS classes for this instance’s list and cards. | NotificationSemantic | — |
styles | Styles for this instance’s list and cards. | NotificationSemantic | — |
onAllRemoved | Runs 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.
| Token | Current topic value |
|---|---|
colorText | rgba(0,0,0,0.88) |
fontSize | 14 |
lineHeight | 1.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.