+ The light-speed iteration of the digital world makes products more complex. However, human consciousness and attention resources are limited. Facing this design contradiction, the pursuit of natural interaction will be the consistent direction of Ant Design.
+
+
+ Natural user cognition: According to cognitive psychology, about 80% of external information is obtained through visual channels. The most important visual elements in the interface design, including layout, colors, illustrations, icons, etc., should fully absorb the laws of nature, thereby reducing the user's cognitive cost and bringing authentic and smooth feelings. In some scenarios, opportunely adding other sensory channels such as hearing, touch can create a richer and more natural product experience.
+
+
+ Natural user behavior: In the interaction with the system, the designer should fully understand the relationship between users, system roles, and task objectives, and also contextually organize system functions and services. At the same time, a series of methods such as behavior analysis, artificial intelligence and sensors could be applied to assist users to make effective decisions and reduce extra operations of users, to save users' mental and physical resources and make human-computer interaction more natural.
+
+ The light-speed iteration of the digital world makes products more complex. However, human consciousness and attention resources are limited. Facing this design contradiction, the pursuit of natural interaction will be the consistent direction of Ant Design.
+
+
+ Natural user cognition: According to cognitive psychology, about 80% of external information is obtained through visual channels. The most important visual elements in the interface design, including layout, colors, illustrations, icons, etc., should fully absorb the laws of nature, thereby reducing the user's cognitive cost and bringing authentic and smooth feelings. In some scenarios, opportunely adding other sensory channels such as hearing, touch can create a richer and more natural product experience.
+
+
+ Natural user behavior: In the interaction with the system, the designer should fully understand the relationship between users, system roles, and task objectives, and also contextually organize system functions and services. At the same time, a series of methods such as behavior analysis, artificial intelligence and sensors could be applied to assist users to make effective decisions and reduce extra operations of users, to save users' mental and physical resources and make human-computer interaction more natural.
+
+
+
+
+ The light-speed iteration of the digital world makes products more complex. However,
+ human consciousness and attention resources are limited. Facing this design
+ contradiction, the pursuit of natural interaction will be the consistent direction of
+ Ant Design.
+
+
+ Natural user cognition: According to cognitive psychology, about 80% of external
+ information is obtained through visual channels. The most important visual elements in
+ the interface design, including layout, colors, illustrations, icons, etc., should fully
+ absorb the laws of nature, thereby reducing the user's cognitive cost and bringing
+ authentic and smooth feelings. In some scenarios, opportunely adding other sensory
+ channels such as hearing, touch can create a richer and more natural product experience.
+
+
+ Natural user behavior: In the interaction with the system, the designer should fully
+ understand the relationship between users, system roles, and task objectives, and also
+ contextually organize system functions and services. At the same time, a series of
+ methods such as behavior analysis, artificial intelligence and sensors could be applied
+ to assist users to make effective decisions and reduce extra operations of users, to
+ save users' mental and physical resources and make human-computer interaction more
+ natural.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default App;
diff --git a/components/watermark/demo/image.md b/components/watermark/demo/image.md
new file mode 100644
index 000000000000..a1ace81b1464
--- /dev/null
+++ b/components/watermark/demo/image.md
@@ -0,0 +1,7 @@
+## zh-CN
+
+通过 `image` 指定图片地址。为保证图片高清且不被拉伸,请设置 width 和 height, 并上传至少两倍的宽高的 logo 图片地址。
+
+## en-US
+
+Specify the image address via 'image'. To ensure that the image is high definition and not stretched, set the width and height, and upload at least twice the width and height of the logo image address.
diff --git a/components/watermark/demo/image.tsx b/components/watermark/demo/image.tsx
new file mode 100644
index 000000000000..53b0664dea0b
--- /dev/null
+++ b/components/watermark/demo/image.tsx
@@ -0,0 +1,14 @@
+import React from 'react';
+import { Watermark } from 'antd';
+
+const App: React.FC = () => (
+
+
+
+);
+
+export default App;
diff --git a/components/watermark/demo/multi-line.md b/components/watermark/demo/multi-line.md
new file mode 100644
index 000000000000..1207f337976c
--- /dev/null
+++ b/components/watermark/demo/multi-line.md
@@ -0,0 +1,7 @@
+## zh-CN
+
+通过 `content` 设置 字符串数组 指定多行文字水印内容。
+
+## en-US
+
+Use 'content' to set a string array to specify multi-line text watermark content.
diff --git a/components/watermark/demo/multi-line.tsx b/components/watermark/demo/multi-line.tsx
new file mode 100644
index 000000000000..b97592ba12ae
--- /dev/null
+++ b/components/watermark/demo/multi-line.tsx
@@ -0,0 +1,10 @@
+import React from 'react';
+import { Watermark } from 'antd';
+
+const App: React.FC = () => (
+
+
+
+);
+
+export default App;
diff --git a/components/watermark/index.en-US.md b/components/watermark/index.en-US.md
new file mode 100644
index 000000000000..dde4404f9632
--- /dev/null
+++ b/components/watermark/index.en-US.md
@@ -0,0 +1,50 @@
+---
+category: Components
+group: Other
+title: Watermark
+cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*wr1ISY50SyYAAAAAAAAAAAAADrJ8AQ/original
+demo:
+ cols: 1
+---
+
+Add specific text or patterns to the page.
+
+## When To Use
+
+- Use when the page needs to be watermarked to identify the copyright.
+- Suitable for preventing information theft.
+
+## Examples
+
+
+Basic
+Multi-line watermark
+Image watermark
+Custom configuration
+
+## API
+
+### Watermark
+
+| Property | Description | Type | Default | Version |
+| --- | --- | --- | --- | --- |
+| width | The width of the watermark, the default value of `content` is its own width | number | 120 | |
+| height | The height of the watermark, the default value of `content` is its own height | number | 64 | |
+| rotate | When the watermark is drawn, the rotation Angle, unit `°` | number | -22 | |
+| zIndex | The z-index of the appended watermark element | number | 9 | |
+| image | Image source, it is recommended to export 2x or 3x image, high priority | string | - | |
+| content | Watermark text content | string \| string[] | - | |
+| font | Text style | [Font](#Font) | [Font](#Font) | |
+| gap | The spacing between watermarks | \[number, number\] | \[200, 200\] | |
+| offset | The offset of the watermark from the upper left corner of the container. The default is `gap/2` | \[number, number\] | \[gap\[0\]/2, gap\[1\]/2\] | |
+
+### Font
+
+
+| 参数 | 说明 | 类型 | 默认值 | 版本 |
+| --- | --- | --- | --- | --- |
+| color | font color | string | rgba(0,0,0,.15) | |
+| fontSize | font size | number | 16 | |
+| fontWeight | font weight | `normal` \| `light` \| `weight` \| number | normal | |
+| fontFamily | font family | string | sans-serif | |
+| fontStyle | font style | `none` \| `normal` \| `italic` \| `oblique` | normal | |
diff --git a/components/watermark/index.tsx b/components/watermark/index.tsx
new file mode 100644
index 000000000000..83debf2f73ba
--- /dev/null
+++ b/components/watermark/index.tsx
@@ -0,0 +1,262 @@
+import React, { useEffect, useRef } from 'react';
+import useMutationObserver from './useMutationObserver';
+
+const FontGap = 3;
+
+const getStyleStr = (style: Record): string => {
+ const styleArr = Object.keys(style).map((item) => {
+ const key = item.replace(/([A-Z])/g, '-$1').toLowerCase();
+ return `${key}: ${style[item]};`;
+ });
+ return styleArr.join(' ');
+};
+
+export interface WatermarkProps {
+ zIndex?: number;
+ rotate?: number;
+ width?: number;
+ height?: number;
+ image?: string;
+ content?: string | string[];
+ font?: {
+ color?: string;
+ fontSize?: number | string;
+ fontWeight?: 'normal' | 'light' | 'weight' | number;
+ fontStyle?: 'none' | 'normal' | 'italic' | 'oblique';
+ fontFamily?: string;
+ };
+ style?: React.CSSProperties;
+ className?: string;
+ gap?: [number, number];
+ offset?: [number, number];
+ children?: React.ReactNode;
+}
+
+const Watermark: React.FC = (props) => {
+ const {
+ /**
+ * The antd content layer zIndex is basically below 10
+ * https://github.com/ant-design/ant-design/blob/6192403b2ce517c017f9e58a32d58774921c10cd/components/style/themes/default.less#L335
+ */
+ zIndex = 9,
+ rotate = -22,
+ width,
+ height,
+ image,
+ content,
+ font = {},
+ style,
+ className,
+ gap = [200, 200],
+ offset,
+ children,
+ } = props;
+
+ const {
+ color = 'rgba(0,0,0,.15)',
+ fontSize = 16,
+ fontWeight = 'normal',
+ fontStyle = 'normal',
+ fontFamily = 'sans-serif',
+ } = font;
+
+ const [gapX, gapY] = gap;
+ const gapXCenter = gapX / 2;
+ const gapYCenter = gapY / 2;
+ const offsetLeft = offset?.[0] ?? gapXCenter;
+ const offsetTop = offset?.[1] ?? gapYCenter;
+
+ const getMarkStyle = (markWidth: number) => {
+ const markStyle: React.CSSProperties = {
+ zIndex,
+ position: 'absolute',
+ left: 0,
+ top: 0,
+ width: '100%',
+ height: '100%',
+ backgroundSize: `${gapX + markWidth}px`,
+ pointerEvents: 'none',
+ backgroundRepeat: 'repeat',
+ };
+
+ /** Calculate the style of the offset */
+ let positionLeft = offsetLeft - gapXCenter;
+ let positionTop = offsetTop - gapYCenter;
+ if (positionLeft > 0) {
+ markStyle.left = `${positionLeft}px`;
+ markStyle.width = `calc(100% - ${positionLeft}px)`;
+ positionLeft = 0;
+ }
+ if (positionTop > 0) {
+ markStyle.top = `${positionTop}px`;
+ markStyle.height = `calc(100% - ${positionTop}px)`;
+ positionTop = 0;
+ }
+ markStyle.backgroundPosition = `${positionLeft}px ${positionTop}px`;
+
+ return markStyle;
+ };
+
+ const containerRef = useRef(null);
+ const watermarkRef = useRef();
+ const { createObserver, destroyObserver } = useMutationObserver();
+
+ const destroyWatermark = () => {
+ if (watermarkRef.current) {
+ watermarkRef.current.remove();
+ watermarkRef.current = undefined;
+ }
+ };
+
+ const reRendering = (mutation: MutationRecord) => {
+ let flag = false;
+ // Whether to delete the watermark node
+ if (mutation.removedNodes.length) {
+ mutation.removedNodes.forEach((node) => {
+ if (node === watermarkRef.current) {
+ flag = true;
+ }
+ });
+ }
+ // Whether the watermark dom property value has been modified
+ if (mutation.type === 'attributes' && mutation.target === watermarkRef.current) {
+ flag = true;
+ }
+ return flag;
+ };
+
+ const appendWatermark = (base64Url: string, markWidth: number) => {
+ if (containerRef.current && watermarkRef.current) {
+ destroyObserver();
+ watermarkRef.current.setAttribute(
+ 'style',
+ getStyleStr({
+ ...getMarkStyle(markWidth),
+ backgroundImage: `url('${base64Url}')`,
+ }),
+ );
+ containerRef.current?.append(watermarkRef.current);
+ createObserver(containerRef.current, (mutations) => {
+ mutations.forEach((mutation) => {
+ if (reRendering(mutation)) {
+ destroyWatermark();
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
+ renderWatermark();
+ }
+ });
+ });
+ }
+ };
+
+ /**
+ * Get the width and height of the watermark. The default values are as follows
+ * Image: [120, 64]; Content: It's calculated by content;
+ */
+ const getMarkSize = (ctx: CanvasRenderingContext2D) => {
+ let defaultWidth = 120;
+ let defaultHeight = 64;
+ if (!image && ctx.measureText) {
+ ctx.font = `${Number(fontSize)}px ${fontFamily}`;
+ const contents = Array.isArray(content) ? content : [content];
+ const widths = contents.map((item) => ctx.measureText(item as string).width);
+ defaultWidth = Math.ceil(Math.max(...widths));
+ defaultHeight = Number(fontSize) * contents.length + (contents.length - 1) * FontGap;
+ }
+ return [width ?? defaultWidth, height ?? defaultHeight];
+ };
+
+ const renderWatermark = () => {
+ const canvas = document.createElement('canvas');
+ const ctx = canvas.getContext('2d');
+
+ if (ctx) {
+ if (!watermarkRef.current) {
+ watermarkRef.current = document.createElement('div');
+ }
+
+ const ratio = window.devicePixelRatio || 1;
+ const [markWidth, markHeight] = getMarkSize(ctx);
+ const canvasWidth = `${(gapX + markWidth) * ratio}px`;
+ const canvasHeight = `${(gapY + markHeight) * ratio}px`;
+ canvas.setAttribute('width', canvasWidth);
+ canvas.setAttribute('height', canvasHeight);
+
+ const mergedMarkWidth = markWidth * ratio;
+ const mergedMarkHeight = markHeight * ratio;
+ const mergedGapXCenter = (gapX * ratio) / 2;
+ const mergedGapYCenter = (gapY * ratio) / 2;
+
+ /** Rotate with the canvas as the center point */
+ const centerX = (mergedMarkWidth + gapX * ratio) / 2;
+ const centerY = (mergedMarkHeight + gapY * ratio) / 2;
+ ctx.translate(centerX, centerY);
+ ctx.rotate((Math.PI / 180) * Number(rotate));
+ ctx.translate(-centerX, -centerY);
+
+ if (image) {
+ const img = new Image();
+ img.onload = () => {
+ ctx.drawImage(img, mergedGapXCenter, mergedGapYCenter, mergedMarkWidth, mergedMarkHeight);
+ appendWatermark(canvas.toDataURL(), markWidth);
+ };
+ img.crossOrigin = 'anonymous';
+ img.referrerPolicy = 'no-referrer';
+ img.src = image;
+ } else {
+ const mergedFontSize = Number(fontSize) * ratio;
+ ctx.font = `${fontStyle} normal ${fontWeight} ${mergedFontSize}px/${mergedMarkHeight}px ${fontFamily}`;
+ ctx.fillStyle = color;
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'top';
+ ctx.translate(mergedMarkWidth / 2, 0);
+ if (Array.isArray(content)) {
+ content?.forEach((item: string, index: number) =>
+ ctx.fillText(
+ item,
+ mergedGapXCenter,
+ mergedGapYCenter + index * (mergedFontSize + FontGap * ratio),
+ ),
+ );
+ } else {
+ ctx.fillText(content ?? '', mergedGapXCenter, mergedGapYCenter);
+ }
+ appendWatermark(canvas.toDataURL(), markWidth);
+ }
+ }
+ };
+
+ useEffect(() => {
+ renderWatermark();
+ }, [
+ rotate,
+ zIndex,
+ width,
+ height,
+ image,
+ content,
+ color,
+ fontSize,
+ fontWeight,
+ fontStyle,
+ fontFamily,
+ gapX,
+ gapY,
+ offsetLeft,
+ offsetTop,
+ ]);
+
+ return (
+