Notification
Global notifications: positions, display times, actions, updates and queues.
When to use
notification shows the event with title, details and next steps. It is suitable for background export, completion of long-running operation or application message. For a short response, Message is enough; Place an important permanent warning in the main content as well.
notification CSS prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. NotificationHolder changes the classes of all placements and parts of the card. App uses notification.prefixCls. The queue, timers, focus and native surface are preserved.
Instance, contents and position
Create a createNotification and place one NotificationHolder inside the desired ConfigProvider. The instance has an independent queue for all positions; certain areas need separate instances.
| Problem | Opportunity | Example |
|---|---|---|
| Show detailed event | open, title, description |
Basic Notice |
| Select semantic status | success/info/warning/error |
Types |
| Show the time until dismissal | duration, showProgress, pauseOnHover |
Display time |
| Collapse notices in one placement | stack |
Notification stack |
| Choose a position and mount node | placement, getContainer |
Placement |
| Replace expectation with result | identical key, actions |
Update |
| Run background task | application model | Export report |
Pass text, a number or a snippet to title and description. Put buttons and links in actions. The placement option selects one of six positions along the edges of the viewport. Setting rtl changes the text direction and keeps the selected edge.
Update and show time
Repeated open with the same key updates the entry, including text, actions, type and placement. To preserve the DOM description when changing status, set the type already when opening, for example info: the appearance or removal of an icon can recreate the content wrapper.
Notices close after 4.5 seconds by default. Set duration: 0 or duration: false to keep one open. For a positive duration, showProgress displays the remaining time. The bar and timer pause together while the pointer hovers with pauseOnHover enabled or focus is inside the card. The export example uses Progress to show how much of the report is ready.
Use closable to change the close icon, set its accessible label or disable the button. If you hide the button on a persistent notice, provide another way to dismiss it. onClose runs when a card starts closing. onAllRemoved runs after the last card leaves the DOM.
By default, the fourth card in the same placement collapses the list. Hover over the stack or move focus inside it to reveal every card. Adjust stack.threshold to change the threshold, or use stack: false to keep the list expanded. To dismiss the oldest notices, set maxCount. This limit applies across all placements of the instance.
Context, design and limitations of
Holder gets local topic and direction from ConfigProvider. theme.components.Notification changes width, zIndexPopup and status backgrounds without reopening. Local CSS holder and post variables take precedence.
Without component override, status backgrounds use colorBgElevated rather than the common colorInfoBg/colorSuccessBg. An empty configuration returns the default width of 384px. Explicit width:undefined is a special case; for a given size, use a number or CSS length, without assuming max-content mode.
Use actions for keyboard-accessible buttons and links. Pass HTML attributes such as data-* or ARIA attributes to the card via props. The card’s onClick receives clicks on the card. The close button handles its own clicks.
Set a shared close icon, classes and styles with ConfigProvider.notification. Both classNames and styles accept an object or a function of { props }. Styles apply in order from provider to instance to individual card. Custom styling example.
getContainer runs in the browser. If it returns no node, the library tries ConfigProvider.getPopupContainer and then document.body. With neither function specified, the list stays next to its holder.
Instead of a manual createNotification/NotificationHolder pair, you can use App: App.useApp() returns a notification from the nearest area. Its defaults are inherited by fields, and parent and nested queues are independent. The App.notification.placement change applies to new notifications.
Examples
Regular notification
createNotification and one holder.
<script lang="ts">
import { Button, NotificationHolder, createNotification } from '@woodger/antd';
const notification = createNotification();
</script>
<NotificationHolder {notification} top={240} id="notification-basic-notices" />
<Button onclick={() => notification.open(({
title: "Documentation updated",
description: "New examples of components have appeared in the catalog."
}))}>{("Show regular notification")}</Button>
Standard icons
success, info, warning and error.
<script lang="ts">
import { Button, NotificationHolder, createNotification } from '@woodger/antd';
const notification = createNotification();
const types = ['success', 'info', 'warning', 'error'] as const;
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<NotificationHolder {notification} top={240} id="notification-types-notices" />
<div class="actions">{#each types as type (type)}
<Button onclick={() => notification[type](({
key: type,
title: `Status: ${type}`,
description: "Standard status icon.",
duration: 0
}))}>{(type)}</Button>
{/each}<Button
onclick={() => notification.destroy()}
>{("Remove type notifications")}</Button></div>
Show time
The bar shows the time left before the notice closes.
<script lang="ts">
import {
Button,
Checkbox,
InputNumber,
NotificationHolder,
createNotification
} from '@woodger/antd';
const notification = createNotification();
let duration = $state(4.5);
let permanent = $state(false);
let pauseOnHover = $state(true);
let showProgress = $state(true);
let closed = $state(0);
</script>
<style>
.settings {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<NotificationHolder {notification} top={240} id="notification-duration-notices" />
<div class="settings">
<InputNumber
aria-label={("Duration Notification")}
min={0}
max={10}
step={0.5}
value={duration}
onValueChange={next => { duration = next ?? 0; }}
/>
<Checkbox bind:checked={permanent}>{("Without automatic closing")}</Checkbox>
<Checkbox bind:checked={showProgress} disabled={permanent || duration === 0}>
{("Show remaining time")}
</Checkbox>
<Checkbox
bind:checked={pauseOnHover}
>{("Pause Notification on hover")}</Checkbox>
<Button onclick={() => notification.info(({
key: 'duration',
title: "Show time",
description: "Hover over or navigate to the close button.",
duration: permanent ? false : duration,
pauseOnHover,
showProgress,
onClose: () => { closed++; }
}))}>{("Show with selected duration")}</Button>
</div>
<output
aria-label={("Closing Notification")}
>{("Closed: ")}{closed}</output>
Its closing
Text, accessible name, disabled and hidden button.
<script lang="ts">
import { Button, Checkbox, NotificationHolder, createNotification } from '@woodger/antd';
const notification = createNotification({ placement: 'bottomLeft' });
let disabled = $state(false);
let hidden = $state(false);
</script>
<style>
.settings {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 16px;
}
</style>
<NotificationHolder {notification} top={240} id="notification-close-notices" />
<div
class="settings"
><Checkbox
bind:checked={disabled}
>{("Disable close button")}</Checkbox>
<Checkbox bind:checked={hidden}>{("Hide close button")}</Checkbox>
<Button onclick={() => notification.open(({
key: 'close',
title: "Its closing",
description: "Settings are applied when displaying or updating a record.",
duration: 0,
closable: hidden ? false : {
disabled,
closeIcon: "Ready",
'aria-label': "End notification"
}
}))}>{("Show your closure")}</Button>
<Button
onclick={() => notification.destroy('close')}
>{("Remove notification manually")}</Button></div>
Your own icon and design
Share the title and border styles and change the icon color for one card.
<script lang="ts">
import { Button, ConfigProvider, NotificationHolder, createNotification } from '@woodger/antd';
const notification = createNotification();
const appearance = {
classNames: { title: 'notification-custom-title' },
styles: { root: 'border: 1px dashed var(--ant-color-warning)' }
};
function showNotice() {
notification.open({
title: ("Own design"),
description,
icon,
duration: 5,
class: 'notification-custom',
styles: {
root: 'border-radius: 12px',
icon: 'color: var(--ant-color-warning)'
}
});
}
</script>
<style>
:global(.notification-custom-title) { font-weight: 600; }
</style>
{#snippet icon()}<span aria-hidden="true">★</span>{/snippet}
{#snippet description()}
<span>{("Label from ")}<strong>Svelte Snippet</strong>{(" with its own design.")}</span>
{/snippet}
<ConfigProvider notification={appearance}>
<NotificationHolder {notification} top={240} id="notification-custom-notices" />
<Button onclick={showNotice}>{("Show your Notification icon")}</Button>
</ConfigProvider>
Provisions
Choose a mount node, one of six screen positions and the text direction.
<script lang="ts">
import {
Button,
Checkbox,
NotificationHolder,
RadioGroup,
createNotification,
type NotificationPlacement
} from '@woodger/antd';
const notification = createNotification();
const placements: NotificationPlacement[] = [
'top', 'topLeft', 'topRight', 'bottom', 'bottomLeft', 'bottomRight'
];
let placement = $state<NotificationPlacement>('topRight');
let container = $state<HTMLDivElement>();
let rtl = $state(false);
</script>
<style>
.settings {
display: grid;
gap: 20px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<NotificationHolder {notification} rtl={rtl || undefined} getContainer={() => container}
top={240} bottom={24} id="notification-placement-notices" />
<div bind:this={container} class="settings">
<RadioGroup
aria-label={("Example Notification position")}
bind:value={placement}
options={(placements)}
/>
<Checkbox bind:checked={rtl}>{("Right-to-left text")}</Checkbox>
<div class="actions"><Button onclick={() => notification.info(({
key: placement,
title: `Position: ${placement}`,
description: "Physical area of the screen.",
placement,
duration: 0
}))}>{("Show in selected position")}</Button>
<Button
onclick={() => notification.destroy()}
>{("Clear Notification provisions")}</Button></div></div>
Update and actions
One key, new result and accept button.
<script lang="ts">
import { Button, NotificationHolder, createNotification } from '@woodger/antd';
const notification = createNotification();
let accepted = $state(0);
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
output {
display: block;
margin-top: 16px;
}
</style>
{#snippet actions()}<Button type="primary" onclick={() => {
accepted++;
notification.destroy('review');
}}>{("Accept notification result")}</Button>{/snippet}
<NotificationHolder {notification} top={240} id="notification-update-notices" />
<div class="actions">
<Button onclick={() => notification.info(({
key: 'review',
title: "Checking the document",
description: "We are waiting for the test result.",
duration: 0
}))}>{("Start checking Notification")}</Button>
<Button onclick={() => notification.success(({
key: 'review',
title: "Document verified",
description: "You can accept the result.",
actions,
duration: 0
}))}>{("Complete Notification check")}</Button>
<Button onclick={() => notification.destroy('review')}>
{("Remove Notification check")}
</Button>
</div>
<output
aria-label={("Actions Notification")}
>{("Accepted: ")}{accepted}</output>
Queue limit
Adding a fourth notice dismisses the oldest one.
<script lang="ts">
import { Button, NotificationHolder, createNotification } from '@woodger/antd';
const notification = createNotification({ maxCount: 3, duration: 0, placement: 'bottomLeft' });
let sequence = $state(0);
</script>
<style>
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<NotificationHolder {notification} top={240} id="notification-queue-notices" />
<div class="actions"><Button onclick={() => notification.info(({
title: `Queue Notification No.${++sequence}`,
description: "The total limit is three entries."
}))}>{("Add to Notification queue")}</Button>
<Button
onclick={() => notification.destroy()}
>{("Clear Notification queue")}</Button></div>
Notification stack
Add four reports, then hover over the stack or move keyboard focus into it.
<script lang="ts">
import {
Button, Checkbox, Flex, InputNumber, NotificationHolder, createNotification
} from '@woodger/antd';
const thresholdId = $props.id();
const notification = createNotification({ duration: 0, placement: 'bottomRight' });
let enabled = $state(true);
let threshold = $state(3);
let hasReports = $state(false);
let sequence = 0;
function reportReady() {
sequence += 1;
notification.success({
title: ("The report is ready"),
description: `report-${sequence}.csv`
});
hasReports = true;
}
</script>
<NotificationHolder {notification} stack={enabled ? { threshold } : false}
onAllRemoved={() => { hasReports = false; }} />
<Flex vertical align="start" gap="medium">
<Flex align="center" wrap gap="small">
<Checkbox bind:checked={enabled}>{("Collapse the list")}</Checkbox>
<label for={thresholdId}>{("Stack threshold")}</label>
<InputNumber id={thresholdId} value={threshold} min={1} max={10} step={1} precision={0}
disabled={!enabled} onValueChange={value => { threshold = value ?? 1; }} />
</Flex>
<Flex wrap gap="small">
<Button type="primary" onclick={reportReady}>
{("Notify when a report is ready")}
</Button>
<Button disabled={!hasReports} onclick={() => notification.destroy()}>
{("Clear notifications")}
</Button>
</Flex>
</Flex>
Component notification Theme
Width, status backgrounds and layer. Changing the topic saves the comment in actions, the queue and the closing date.
<script lang="ts">
import {
Button,
Checkbox,
ConfigProvider,
Input,
NotificationHolder,
RadioGroup,
createNotification
} from '@woodger/antd';
import type { NotificationType } from '@woodger/antd';
const notification = createNotification({ pauseOnHover: false });
let enabled = $state(true);
let resetWidth = $state(false);
let status = $state<NotificationType>('info');
let comment = $state(("Draft comment"));
const types = ['info', 'success', 'warning', 'error'] as const;
const tokens = {
zIndexPopup: 2400,
progressBg: '#d48806',
colorInfoBg: '#fffbe6',
colorSuccessBg: '#f6ffed',
colorWarningBg: '#fff7e6',
colorErrorBg: '#fff1f0'
};
</script>
<style>
.settings {
display: grid;
gap: 24px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.status-settings, .notice-actions {
display: grid;
gap: 12px;
min-width: 0;
max-width: 100%;
}
label {
display: grid;
gap: 8px;
}
</style>
{#snippet actions()}
<div class="notice-actions">
<label>{("Comment\n ")}<Input bind:value={comment} aria-label={("Comment thread Notification")} />
</label>
<Button onclick={() => notification.destroy('theme')}>{("Ready")}</Button>
</div>
{/snippet}
<ConfigProvider direction="rtl" theme={{
cssVar: { prefix: 'notification-demo' },
token: { colorInfoBg: '#fffbe6' },
components: { Notification: enabled ? { ...tokens, width: resetWidth ? undefined : 480 } : {} }
}}>
<NotificationHolder {notification} top={240} bottom={24} id="notification-theme-notices" />
<div class="settings">
<Checkbox bind:checked={enabled}>{("Apply Notification tokens")}</Checkbox>
<Checkbox bind:checked={resetWidth} disabled={!enabled}>
{("Send width: undefined")}
</Checkbox>
<div class="status-settings">
<span>{("Notification status")}</span>
<RadioGroup
aria-label={("Thread status Notification")}
bind:value={status}
options={(types)}
style="
display: flex;
flex-wrap: wrap;
gap: 8px;
"
/>
</div>
<div class="actions">
<Button onclick={() => notification.open(({
key: 'theme', type: status, title: "Notification Theme",
description: "The topic is updated without resetting the comment and actions.", actions, duration: 0
}))}>{("Check topic Notification")}</Button>
<Button onclick={() => notification.info(({
key: 'timed-theme', title: "Two second notification",
description: "Switching the theme does not prolong the display.", duration: 2, showProgress: true,
class: 'notification-theme-timed'
}))}>{("Show for 2 seconds")}</Button>
</div>
</div>
</ConfigProvider>
Export report
Operation progress, success, error, retry, cancel and real CSV.
NotificationExample.svelte<script lang="ts"> import { onDestroy } from 'svelte'; import { Button, Checkbox, NotificationHolder, Progress, Select, createNotification, type NotificationPlacement } from '@woodger/antd'; import { createNotificationExport } from './notification-export.model.svelte'; const notification = createNotification({ maxCount: 3 }); let failNext = $state(false); let placement = $state<NotificationPlacement>('topRight'); let result = $state(("Prepare a report and download it from the notification.")); let downloadUrl: string | undefined; const placements = ['top', 'topLeft', 'topRight', 'bottom', 'bottomLeft', 'bottomRight'].map( (value) => ({ value: value as NotificationPlacement, label: value }) ); const model = createNotificationExport({ onReady() { result = ("The report is ready for downloading."); notification.success( ({ key: 'export', title: "The report is ready", description: progress, placement, duration: 0, actions: ready, role: 'status' }) ); }, onError() { result = ("Failed to prepare report. Please try again."); notification.error( ({ key: 'export', title: "Failed to prepare report", description: progress, placement, duration: 0, actions: retry }) ); } }); function releaseDownload() { if (downloadUrl) URL.revokeObjectURL(downloadUrl); downloadUrl = undefined; } function start() { const failed = failNext; if (!model.start(failed)) { return; } failNext = false; releaseDownload(); result = ("Preparing a report..."); notification.info( ({ key: 'export', title: "Preparing a report", description: progress, actions: pending, placement, duration: 0, role: 'status' }) ); } function cancel() { if (!model.cancel()) { return; } result = ("Export cancelled."); notification.info( ({ key: 'export', title: "Export canceled", description: progress, placement, duration: 0, actions: retry, role: 'status' }) ); } function download() { const report = model.report; if (!report) { return; } releaseDownload(); downloadUrl = URL.createObjectURL(new Blob([report], { type: 'text/csv;charset=utf-8' })); const link = document.createElement('a'); link.href = downloadUrl; link.download = 'report.csv'; document.body.append(link); link.click(); link.remove(); result = ("Report downloaded."); } function reset() { model.reset(); releaseDownload(); notification.destroy(); result = ("Export example reset."); } onDestroy(() => { model.destroy(); releaseDownload(); }); </script> <style> .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; } .placement { width: 180px; } output { display: block; margin-top: 20px; color: var(--ant-color-text-secondary); } .phase { margin-block: 0 var(--ant-margin-sm); } </style> {#snippet progress()}<p class="phase">{(model.phase)}</p><Progress percent={model.percent} status={model.status === 'preparing' ? 'active' : model.status === 'error' ? 'exception' : undefined} aria-label={("Report preparation")} />{/snippet} {#snippet pending()}<Button onclick={cancel}>{("Cancel export")}</Button>{/snippet} {#snippet retry()}<Button type="primary" onclick={start} >{("Repeat export")}</Button>{/snippet} {#snippet ready()} <span class="actions"><Button type="primary" onclick={download}> {("Download report")} </Button><Button onclick={() => notification.destroy('export')} >{("Close export result")}</Button></span> {/snippet} <NotificationHolder {notification} id="showcase-notifications" /> <div class="actions" ><Button type="primary" loading={model.status === 'preparing'} onclick={start} >{("Export report")}</Button><Checkbox bind:checked={failNext} >{("Next export error")}</Checkbox><div class="placement" ><Select aria-label={("Position Notification")} bind:value={placement} options={(placements)} /></div><Button onclick={reset} >{("Reset example Notification")}</Button></div> <output aria-label={("Result of the Notification example")}>{result}</output>notification-export.model.svelte.tstype ExportState = | { status: 'idle'; percent: 0; phase: string } | { status: 'preparing'; percent: number; phase: string } | { status: 'ready'; percent: 100; phase: string; report: string } | { status: 'error' | 'cancelled'; percent: number; phase: string }; export function createNotificationExport(callbacks: { onReady: () => void; onError: () => void }) { let state = $state.raw<ExportState>({ status: 'idle', percent: 0, phase: "Prepare a report." }); let generation = 0; let active = true; const timers = new Set<ReturnType<typeof setTimeout>>(); function clear() { generation++; for (const timer of timers) clearTimeout(timer); timers.clear(); } function start(failed = false): boolean { if (!active || state.status === 'preparing') { return false; } clear(); const current = generation; state = { status: 'preparing', percent: 0, phase: "After preparation, a download button will appear here." }; function schedule(delay: number, update: () => void) { const timer = setTimeout( () => { timers.delete(timer); if (active && current === generation && state.status === 'preparing') update(); }, delay ); timers.add(timer); } for (const stage of [ { delay: 200, percent: 25, phase: "Collecting data..." }, { delay: 450, percent: 65, phase: "Generating CSV…" }, { delay: 600, percent: 90, phase: "Checking the file..." } ]) { schedule( stage.delay, () => { state = { status: 'preparing', percent: stage.percent, phase: stage.phase }; } ); } schedule(700, () => { if (failed) { state = { status: 'error', percent: 90, phase: "Data saved. Try exporting again." }; callbacks.onError(); } else { state = { status: 'ready', percent: 100, phase: "CSV file contains two entries. It can be downloaded now.", report: '\uFEFFname,framework\r\nAnna,Svelte\r\nBoris,TypeScript\r\n' }; callbacks.onReady(); } }); return true; } return { get status() { return state.status; }, get percent() { return state.percent; }, get phase() { return state.phase; }, get report() { return state.status === 'ready' ? state.report : undefined; }, start, cancel() { if (state.status !== 'preparing') { return false; } clear(); state = { status: 'cancelled', percent: state.percent, phase: "Report preparation has been cancelled." }; return true; }, reset() { clear(); state = { status: 'idle', percent: 0, phase: "Prepare a report." }; }, destroy() { active = false; clear(); } }; }
NotificationHolder changes the classes of all placements and parts of the card. App uses notification.prefixCls. The queue, timers, focus and native surface are preserved.
CSS prefixes notification
Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.
<script lang="ts">
import {
Checkbox,
ConfigProvider,
NotificationHolder,
createNotification,
Button
} from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-notification' : '');
const notification = createNotification({ duration: 0 });
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("General prefix Notification suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Notification")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'notification-theme' } }}>
<div class="prefix-stage">
<NotificationHolder {notification} prefixCls={localPrefix} top={240} />
<Button onclick={() => notification.success(({
key: 'prefix',
title: "Notification with prefix",
description: "Changing namespace saves the current card."
}))}>{("Show Notification with prefix")}</Button>
<Button onclick={() => notification.destroy()}>
{("Close Notification with prefix")}
</Button>
</div>
</ConfigProvider>
<output
aria-label={("CSS prefix Notification")}
>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("NotificationHolder changes the classes of all placements and parts of the card. App uses notification.prefixCls. The queue, timers, focus and native surface are preserved.")}
</p>
</div>
API
| Theme | Example or limitation |
|---|---|
| Hooks usage (recommended) | Svelte: createNotification and one NotificationHolder in the required context. |
| Duration after which the notification box is closed | Seconds, false/0 and pause on hover. |
| Notification with icon | Four standard statuses. |
| Custom close button | Custom label, accessible name, disabled and hide button. |
| Customized Icon | Snippet icon and description. |
| Placement | All six physical areas of the screen. |
| Update Message Content | Update by key and action inside the notification. |
| Stack | Set the collapse threshold and expand the stack with the keyboard or pointer. |
| Show with progress | The bar tracks the notice’s remaining display time. |
| Customize progress bar color | The notification theme’s progressBg sets the bar color. |
| Custom semantic styles | Extend the provider’s shared classes and styles for one card. |
NotificationInstance
| Property | Description | Type | Default |
|---|---|---|---|
open | Create or update a record by key. | (config: NotificationConfig) => void | — |
info | Information status. | (config) => void | info |
success | Successful operation. | (config) => void | success |
warning | Warning. | (config) => void | warning |
error | Error. | (config) => void | error |
destroy | Close one entry or the entire queue. | (key?: string | number) => void | — |
NotificationConfig
| Property | Description | Type | Default |
|---|---|---|---|
title | Title and available name. | NotificationContent | — |
description | Notification details. | NotificationContent | — |
actions | Buttons and links for further actions. | NotificationContent | — |
type | Standard status icon. | success | info | warning | error | — |
icon | Own icon. | NotificationContent | by type |
key | Non-duplicate update ID. | string | number | is generated |
placement | top/bottom, topLeft/topRight, bottomLeft/bottomRight. | NotificationPlacement | topRight |
duration | Seconds; false and 0 disable the timer. | number | false | 4.5 |
pauseOnHover | Pause the timer under the pointer. | boolean | true |
closable | Standard close button settings. | boolean | NotificationClosable | true |
closeIcon | Own label; false/null hide the button. | NotificationContent | cross |
role | Urgency of the announcement. | alert | status | alert |
onClose | Start of closing. Unmount holder callback is not called. | () => void | — |
class | Record root class. | string | — |
style | CSS of the entry root. | string | — |
classNames | CSS classes for individual parts of the card. | NotificationSemantic | — |
styles | Styles for individual parts of the card. | NotificationSemantic | — |
showProgress | Shows the time remaining before dismissal. | boolean | false |
props | Native card attributes, including data-* and ARIA. | NotificationRootAttributes | — |
onClick | Handles clicks on the card. The close button handles its own clicks. | (event: MouseEvent) => void | — |
NotificationClosable
| Property | Description | Type | Default |
|---|---|---|---|
disabled | Disable standard button. | boolean | false |
closeIcon | Takes precedence over closeIcon configuration. | NotificationContent | cross |
aria-label | Available button name. | string | locale.closeText |
onClose | Runs before the card’s onClose when the close button is pressed or the timer expires. | () => void | — |
createNotification options
| 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 | — |
NotificationHolder
| Property | Description | Type | Default |
|---|---|---|---|
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 | — |
notification | Queue instance; one connected holder. | NotificationInstance | is required |
id | Surface identifier with all placements. | string | — |
class | Surface class. | string | — |
style | CSS surfaces. | string | — |
Instead of React hook/static methods, an independent createNotification and NotificationHolder are used. Open methods return void; closing is done by destroy(key) or a standard button.
Semantic DOM
The list and listContent slots apply to the list. The remaining slots apply to a card.
| Slot | CSS class | Purpose |
|---|---|---|
list | .ant-notification-list | Individual placement group. |
listContent | .ant-notification-list-content | List of entries. |
root | .ant-notification-notice | Record with role, available name, class/style. |
wrapper | .ant-notification-notice-wrapper | Icon and text; is created only if there is an icon. |
section | .ant-notification-notice-section | title/description pair; is created only if both blocks are present. |
icon | .ant-notification-notice-icon | Decorative badge. |
title | .ant-notification-notice-title | Heading. |
description | .ant-notification-notice-description | Description. |
actions | .ant-notification-notice-actions | Actions directly at the root of the post, next to the wrapper or text. |
close | .ant-notification-notice-close | Close button. |
progress | .ant-notification-notice-progress | Bar showing the remaining display time. |
Registration tokens
In the theme example, progressBg sets the bar color. Choose “Show for 2 seconds” to see it.
| Token | Purpose |
|---|---|
width | Card width: number in px or CSS length; limited to viewport. |
zIndexPopup | CSS group placements layer; native popover remains in the top layer. |
progressBg | Color of the countdown bar. |
colorInfoBg | Explicit background of the info record. |
colorSuccessBg | Explicit background of success record. |
colorWarningBg | Explicit background of warning record. |
colorErrorBg | Explicit background of error record. |
| Token | Meaning |
|---|---|
colorBgElevated | #ffffff |
colorText | rgba(0,0,0,0.88) |
colorTextHeading | rgba(0,0,0,0.88) |
colorSuccess | #52c41a |
colorError | #ff4d4f |
colorInfo | #1677ff |
colorWarning | #faad14 |
borderRadiusLG | 8 |
FAQ
How to get the ConfigProvider context?
Place the NotificationHolder of your createNotification inside the provider. An instance requires one holder.
What is the difference between notification and Message?
notification is designed for title, details and actions. Message gives a short temporary response.
How to update an existing entry?
Repeat open with the same key and new settings.
How to save DOM descriptions when changing status?
Set the type already upon opening. Adding or removing an icon can recreate the text wrapper.
When does the timer pause?
With hover with pauseOnHover and with focus inside actions. false/0 disables auto-close.
How do I change the countdown color?
Set theme.components.Notification.progressBg and enable showProgress. In the theme example, choose the two-second notification.
Where did the previous notices go?
Move focus into the stack to reveal its cards. If you set a queue limit, adding a notice can dismiss the oldest one.
Do I need to recreate the notification after changing the theme?
No. Design tokens are refreshed reactively, maintaining the queue and closing dates.
Why are the status backgrounds the same?
The default is colorBgElevated. Different backgrounds can be set with notification component tokens.
How to return the standard width?
Remove override or pass an empty component configuration. An explicit width:undefined is different from a missing field.