Ant Design Svelte

Watermark

Watermarks: text, images, settings and inheritance in windows.

When to use

Watermark adds a repeatable text or graphic background to a document, report or image. The content of the page remains the main one, the sign remains an additional visual mark. It can be inherited in child Modal and Drawer.

Text, image and geometry

content accepts a string, a WatermarkText object, or an array of strings with an individual font. Image takes precedence over text. If the image does not load, the specified content serves as a fallback.

Problem Opportunity Example
Add text background content Main sign
Customize individual lines WatermarkText.font Several lines
Use logo with fallback image, content Image
Select angle and pitch rotate, gap, offset Geometry
Pass the sign through the window inherit Modal and Drawer
Check external removal onRemove Recovery

width/height sets the size of the pattern, rotate — the angle in degrees, gap — the distance between repetitions. offset specifies the offset from the top left edge; without it, half of the gap is used. For the image, choose a resolution that is sufficient for the expected output size.

font specifies color, size, family, saturation, style and alignment. Setting a specific line takes precedence over the general one. For a dark background, choose font.color explicitly, maintaining the readability of the main document.

Canvas, container and inheritance

Canvas creates a drawing in the browser, after which a repeatable PNG background is inserted into the document. A visible canvas in the content is not needed. SSR outputs children; the layer appears after mount, so don't expect a ready-made background without JavaScript.

The container uses overflow:hidden. Pop-up content should be placed through the portals provided by its components. Changing overflow via style changes the drawing limitation, but requires checking your own composition.

inherit passes the substrate to the child Modal/Drawer. Example allows you to disable inheritance before opening. This is component context, not automatic coverage of any external popup or arbitrary DOM outside the scope.

Restoration and registration

onRemove reports external removal of the watermark layer; runtime restores it. The regular unmount callback does not call. The demo separately shows removing a layer via the DOM and normally disabling the component.

ConfigProvider.watermark specifies the class/style of the container, local values ​​are applied after them. Root is accessible via bind:nativeElement after mount. There are no public semantic classNames/styles and no separate set of Watermark component design tokens.

Common tokens participate in default font.color/fontSize and zIndex; the explicit properties of the component specify them. font refers to the Canvas image, so the CSS color of the outer container is not a replacement for font.color.

Examples

Project document

Repeating text is placed on top of the content and skips clicks.

Regular watermark

Text over content.

Each line inherits a common font and can specify its own parameters.

Several lines

General font and parameters of each line.

If there is an image error, text content is used.

Image and backup text

Checking successful and failed loading.

Options change the design of an existing layer.

Sign settings

Text, size, angle, pitch, offset and layer.

Document in Modal

Inherited watermark.

Modal and Drawer

Inheritance can be disabled before opening the window.

External removal of a layer calls onRemove, after which the layer is restored.
Deletions: 0

Layer restoration

External DOM removal and standard component removal.

Local style specifies the general settings of the container.

Content with a repeating watermark.

Watermark in Modal

The watermark is inherited through the context.

Protected document

Original example from the review with legacy Modal.

API

Five example themes were checked against ant.design 6.7.0 and the public Svelte API of the installed package.

Example themes
ThemeExample or limitation
BasicRepeating inscription on top of the document.
Multi-line watermarkSeveral lines with your own font.
Image watermarkImage and text for loading error.
Custom configurationText, angle, size, pitch, offset and layer.
Modal or DrawerInheritance into child windows and its disabling.

Watermark

PropertyDescriptionTypeDefault
contentString or object text/font; the array creates multiple rows.WatermarkContent | readonly WatermarkContent[]—
imageImage address. Takes precedence over text; content serves as a fallback in case of error.string—
widthWidth of one character; text without an explicit width is measured by Canvas.number120 for picture
heightHeight of one character.number64 for picture
rotateRotation in degrees.number-22
gapThe distance between characters horizontally and vertically.readonly [number, number][100, 100]
offsetOffset of the first character relative to the container.readonly [number, number]gap / 2
zIndexLayer inside the container.number999
fontFont and color for Canvas; a separate line can clarify these parameters.WatermarkFont14px, rgba(0,0,0,0.15)
inheritPass the sign to the child Modal and Drawer through the context.booleantrue
onRemoveExternal layer removal. Regular removal of the callback component does not cause any problems.() => void—
nativeElementbind:nativeElement gets the container after mount.HTMLDivElement—
childrenDocument content.Snippet—
styleCSS container; local styles come after ConfigProvider.watermark.string—
classContainer class. Additionally, rootClassName is supported.string—

WatermarkFont

PropertyDescriptionTypeDefault
colorText color.Canvas fillStylergba(0,0,0,0.15)
fontSizeNumeric font size in pixels.number | string14
fontWeightSaturation.number | normal | lighter | bold | boldernormal
fontStyleInscription.none | normal | italic | obliquenormal
fontFamilyFont family.stringsans-serif
textAlignLine alignment.CanvasTextAligncenter

WatermarkText

PropertyDescriptionTypeDefault
textContents of the string.string—
fontParameters for this line only.WatermarkFontcommon font

React children replaced with Svelte Snippet. bind:nativeElement allows you to get a container; ConfigProvider.watermark accepts class and style.

Semantic DOM

The actual markup elements are described below. Watermark does not provide classNames/styles or named semantic slots.

Actual markings
ElementPurpose
containerA relatively positioned div, accessible via nativeElement.
layerAbsolute div with PNG background, aria-hidden and pointer-events: none.
childrenThe content remains normal interactive markup.

Registration tokens

There are no separate component tokens. The drawing is adjusted through font, gap, offset and rotate; container - via class/style and ConfigProvider.watermark.

FAQ

Where is the visible Canvas?

Canvas only creates an image. The page uses a repeating PNG background; it appears after mount.

Why is the content cut off?

The container has overflow:hidden. For pop-up elements, use their portal mechanism.

How to choose a color for a dark theme?

Pass font.color. There are no separate Watermark component tokens.

Why is onRemove needed?

It reports an external layer deletion, which runtime restores. Regular unmount does not cause it.

How to decorate a container?

Via class/style or ConfigProvider.watermark. There are no semantic slots yet.