Project document
Repeating text is placed on top of the content and skips clicks.
Watermarks: text, images, settings and inheritance in windows.
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 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.
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.
Text over content.
<script lang="ts">
import { Watermark } from '@woodger/antd';
</script>
<style>
.document {
min-height: 220px;
padding: 24px;
}
p {
margin: 0 0 16px;
line-height: 1.7;
}
</style>
<Watermark content={("woodger")}>
<article class="document"><p>{("Project document")}</p><p>{("Repeating text is placed on top of the content and skips clicks.")}</p></article>
</Watermark>
General font and parameters of each line.
<script lang="ts">
import { Watermark } from '@woodger/antd';
</script>
<style>
.document {
min-height: 240px;
padding: 24px;
line-height: 1.7;
}
</style>
<Watermark content={([
'woodger',
{ text: "Internal document", font: { fontSize: 12, fontWeight: 600 } },
{ text: "Version 2026", font: { fontSize: 10, fontStyle: 'italic' } }
])} gap={[60, 60]}>
<article class="document">{("Each line inherits a common font and can specify its own parameters.")}</article>
</Watermark>
Checking successful and failed loading.
<script lang="ts">
import { Checkbox, Watermark } from '@woodger/antd';
let broken = $state(false);
</script>
<style>
.settings { margin-bottom: 20px; }
.document {
min-height: 220px;
padding: 24px;
}
</style>
<div
class="settings"
><Checkbox
bind:checked={broken}
>{("Check image error")}</Checkbox></div>
<Watermark image={broken ? 'data:image/png;base64,AA==' : '/favicon.png'}
content={("woodger")} width={48} height={48} gap={[80, 80]}>
<article
class="document"
>{("If there is an image error, text content is used.")}</article>
</Watermark>
Text, size, angle, pitch, offset and layer.
<script lang="ts">
import { Input, InputNumber, Watermark } from '@woodger/antd';
const id = $props.id();
let content = $state<string | undefined>('woodger');
let values = $state({
fontSize: 16,
rotate: -22,
gapX: 80,
gapY: 80,
offsetX: 40,
offsetY: 40,
zIndex: 9
});
const fields = [
{ key: 'fontSize', label: "Text size", min: 8, max: 40 },
{ key: 'rotate', label: "Angle", min: -180, max: 180 },
{ key: 'gapX', label: "Interval X", min: 0, max: 200 },
{ key: 'gapY', label: "Y Interval", min: 0, max: 200 },
{ key: 'offsetX', label: "Offset X", min: 0, max: 200 },
{ key: 'offsetY', label: "Y offset", min: 0, max: 200 },
{ key: 'zIndex', label: "Layer", min: 0, max: 999 }
] as const;
</script>
<style>
.settings {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
gap: 16px;
margin-bottom: 24px;
}
.field {
display: grid;
gap: 8px;
min-width: 0;
}
.document {
min-height: 220px;
padding: 24px;
}
</style>
<div class="settings">
<div
class="field"
><label
for={`${id}-text`}
>{("Sign text")}</label><Input
id={`${id}-text`}
bind:value={content}
/></div>
{#each fields as field (field.key)}
<div class="field"><label for={`${id}-${field.key}`}>{(field.label)}</label>
<InputNumber id={`${id}-${field.key}`} value={values[field.key]} min={field.min} max={field
.max}
onValueChange={next => { values[field.key] = next ?? field.min; }} />
</div>
{/each}
</div>
<Watermark content={(content ?? '')} font={{ fontSize: values.fontSize }} rotate={values.rotate}
gap={[values.gapX, values.gapY]} offset={[values.offsetX, values.offsetY]} zIndex={values.zIndex}>
<article
class="document"
>{("Options change the design of an existing layer.")}</article>
</Watermark>
Inheritance can be disabled before opening the window.
<script lang="ts">
import { Button, Checkbox, Drawer, Modal, Watermark } from '@woodger/antd';
let inherit = $state(true);
let modal = $state(false);
let drawer = $state(false);
</script>
<style>
.settings { margin-bottom: 20px; }
.document {
min-height: 180px;
padding: 24px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.inside { min-height: 160px; }
</style>
<div
class="settings"
><Checkbox
bind:checked={inherit}
>{("Inherit in windows")}</Checkbox></div>
<Watermark content={("woodger · documents")} {inherit}>
<div class="document"><div class="actions">
<Button onclick={() => { modal = true; }}>{("Show Modal")}</Button>
<Button onclick={() => { drawer = true; }}>{("Show Drawer")}</Button>
</div></div>
<Modal
title={("Document in Modal")}
bind:open={modal}
footer={null}
><div
class="inside"
>{("Inherited watermark.")}</div></Modal>
<Drawer
title={("Document in Drawer")}
bind:open={drawer}
><div
class="inside"
>{("Inherited watermark.")}</div></Drawer>
</Watermark>
External DOM removal and standard component removal.
<script lang="ts">
import { Button, Watermark } from '@woodger/antd';
let visible = $state(true);
let nativeElement = $state<HTMLDivElement>();
let removed = $state(0);
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.document {
min-height: 180px;
padding: 24px;
}
</style>
<div class="example">
<div class="actions">
<Button disabled={!visible} onclick={() => {
const layer = nativeElement?.querySelector(':scope > div[style*="background-image"]');
layer?.remove();
}}>{("Delete layer via DOM")}</Button>
<Button onclick={() => { visible = !visible; }}>{(visible ? "Remove component" : "Return component")}</Button>
</div>
{#if visible}
<Watermark
content={("woodger")}
bind:nativeElement
onRemove={() => { removed++; }}
>
<div class="document">{("External removal of a layer calls onRemove, after which the layer is restored.")}</div>
</Watermark>
{/if}
<output
aria-label={("Remove Watermark layer")}
>{("Deletions: ")}{removed}</output>
</div>
ConfigProvider.watermark and local style.
<script lang="ts">
import { ConfigProvider, Watermark } from '@woodger/antd';
</script>
<style>
.document {
min-height: 180px;
padding: 24px;
}
</style>
<ConfigProvider watermark={{
class: 'watermark-provider',
style: `
border: 1px solid var(--ant-color-primary-border);
border-radius: 12px;
`
}}>
<Watermark content={("woodger")} style="border-radius: 20px">
<div
class="document"
>{("Local style specifies the general settings of the container.")}</div>
</Watermark>
</ConfigProvider>
Original example from the review with legacy Modal.
<script lang="ts">
import { Button, Modal, Watermark } from '@woodger/antd';
let open = $state(false);
</script>
<Watermark content={(['Ant Design', { text: 'Svelte 5', font: { fontSize: 12 } }])}>
<div style="
padding: 40px;
min-height: 180px;
"><p>
{("Content with a repeating watermark.")}
</p><Button
onclick={() => { open = true; }}
>{("Open protected window")}</Button></div>
<Modal title={("Watermark in Modal")} bind:open footer={null}>
<p>
{("The watermark is inherited through the context.")}
</p>
</Modal>
</Watermark>
Five example themes were checked against ant.design 6.7.0 and the public Svelte API of the installed package.
| Theme | Example or limitation |
|---|---|
| Basic | Repeating inscription on top of the document. |
| Multi-line watermark | Several lines with your own font. |
| Image watermark | Image and text for loading error. |
| Custom configuration | Text, angle, size, pitch, offset and layer. |
| Modal or Drawer | Inheritance into child windows and its disabling. |
| Property | Description | Type | Default |
|---|---|---|---|
content | String or object text/font; the array creates multiple rows. | WatermarkContent | readonly WatermarkContent[] | — |
image | Image address. Takes precedence over text; content serves as a fallback in case of error. | string | — |
width | Width of one character; text without an explicit width is measured by Canvas. | number | 120 for picture |
height | Height of one character. | number | 64 for picture |
rotate | Rotation in degrees. | number | -22 |
gap | The distance between characters horizontally and vertically. | readonly [number, number] | [100, 100] |
offset | Offset of the first character relative to the container. | readonly [number, number] | gap / 2 |
zIndex | Layer inside the container. | number | 999 |
font | Font and color for Canvas; a separate line can clarify these parameters. | WatermarkFont | 14px, rgba(0,0,0,0.15) |
inherit | Pass the sign to the child Modal and Drawer through the context. | boolean | true |
onRemove | External layer removal. Regular removal of the callback component does not cause any problems. | () => void | — |
nativeElement | bind:nativeElement gets the container after mount. | HTMLDivElement | — |
children | Document content. | Snippet | — |
style | CSS container; local styles come after ConfigProvider.watermark. | string | — |
class | Container class. Additionally, rootClassName is supported. | string | — |
| Property | Description | Type | Default |
|---|---|---|---|
color | Text color. | Canvas fillStyle | rgba(0,0,0,0.15) |
fontSize | Numeric font size in pixels. | number | string | 14 |
fontWeight | Saturation. | number | normal | lighter | bold | bolder | normal |
fontStyle | Inscription. | none | normal | italic | oblique | normal |
fontFamily | Font family. | string | sans-serif |
textAlign | Line alignment. | CanvasTextAlign | center |
| Property | Description | Type | Default |
|---|---|---|---|
text | Contents of the string. | string | — |
font | Parameters for this line only. | WatermarkFont | common font |
React children replaced with Svelte Snippet. bind:nativeElement allows you to get a container; ConfigProvider.watermark accepts class and style.
The actual markup elements are described below. Watermark does not provide classNames/styles or named semantic slots.
| Element | Purpose |
|---|---|
container | A relatively positioned div, accessible via nativeElement. |
layer | Absolute div with PNG background, aria-hidden and pointer-events: none. |
children | The content remains normal interactive markup. |
There are no separate component tokens. The drawing is adjusted through font, gap, offset and rotate; container - via class/style and ConfigProvider.watermark.
Canvas only creates an image. The page uses a repeating PNG background; it appears after mount.
The container has overflow:hidden. For pop-up elements, use their portal mechanism.
Pass font.color. There are no separate Watermark component tokens.
onRemove needed?It reports an external layer deletion, which runtime restores. Regular unmount does not cause it.
Via class/style or ConfigProvider.watermark. There are no semantic slots yet.