2022-12-08 18:06:36 +08:00
---
category: Components
2023-08-08 19:48:41 +08:00
group: Feedback
2022-12-08 18:06:36 +08:00
title: Watermark
2024-03-22 14:22:42 +08:00
description: Add specific text or patterns to the page.
2022-12-08 18:06:36 +08:00
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*wr1ISY50SyYAAAAAAAAAAAAADrJ8AQ/original
2023-02-09 22:17:31 +08:00
coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*duAQQbjHlHQAAAAAAAAAAAAADrJ8AQ/original
2022-12-08 18:06:36 +08:00
demo:
cols: 1
2024-04-02 14:05:03 +08:00
tag: 5.1.0
2022-12-08 18:06:36 +08:00
---
## When To Use
- Use when the page needs to be watermarked to identify the copyright.
- Suitable for preventing information theft.
## Examples
<!-- prettier - ignore -->
< code src = "./demo/basic.tsx" > Basic< / code >
< code src = "./demo/multi-line.tsx" > Multi-line watermark< / code >
< code src = "./demo/image.tsx" > Image watermark< / code >
< code src = "./demo/custom.tsx" > Custom configuration< / code >
2023-08-08 16:48:26 +08:00
< code src = "./demo/portal.tsx" > Modal or Drawer< / code >
2022-12-08 18:06:36 +08:00
## API
2023-08-08 18:27:48 +08:00
Common props ref: [Common props](/docs/react/common-props)
2024-04-02 14:05:03 +08:00
> This component is available since `antd@5.1.0`.
2024-01-13 14:27:42 +08:00
2022-12-08 18:06:36 +08:00
### 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 | |
2023-10-13 15:16:08 +08:00
| inherit | Pass the watermark to the pop-up component such as Modal, Drawer | boolean | true | 5.11.0 |
2022-12-08 18:06:36 +08:00
| rotate | When the watermark is drawn, the rotation Angle, unit `°` | number | -22 | |
| zIndex | The z-index of the appended watermark element | number | 9 | |
2023-02-28 11:20:15 +08:00
| image | Image source, it is recommended to export 2x or 3x image, high priority (support base64 format) | string | - | |
2022-12-08 18:06:36 +08:00
| content | Watermark text content | string \| string[] | - | |
2022-12-22 14:12:26 +08:00
| font | Text style | [Font ](#font ) | [Font ](#font ) | |
2022-12-13 15:47:57 +08:00
| gap | The spacing between watermarks | \[number, number\] | \[100, 100\] | |
2022-12-08 18:06:36 +08:00
| 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
<!-- prettier - ignore -->
2022-12-08 22:32:37 +08:00
| Property | Description | Type | Default | Version |
2022-12-08 18:06:36 +08:00
| --- | --- | --- | --- | --- |
2023-09-18 09:56:32 +08:00
| color | font color | [CanvasFillStrokeStyles.fillStyle ](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillStyle ) | rgba(0,0,0,.15) | |
2022-12-08 18:06:36 +08:00
| 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 | |
2023-09-18 09:56:32 +08:00
| textAlign | specify the text alignment direction | [CanvasTextAlign ](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textAlign ) | `center` | 5.10.0 |
2023-02-28 11:20:15 +08:00
2023-04-11 10:25:24 +08:00
## Design Token
< ComponentTokenTable component = "Watermark" > < / ComponentTokenTable >
2023-02-28 11:20:15 +08:00
## FAQ
### Handle abnormal image watermarks
When using an image watermark and the image loads abnormally, you can add `content` at the same time to prevent the watermark from becoming invalid (since 5.2.3).
```typescript jsx
< Watermark
height={30}
width={130}
content="Ant Design"
image="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*lkAoRbywo0oAAAAAAAAAAAAADrJ8AQ/original"
>
< div style = {{ height: 500 } } / >
< / Watermark >
```
2024-08-08 17:03:07 +08:00
### Why `overflow: hidden` style is added since version 5.18.0?
User can hide the watermark by setting the container height to 0 through the developer tool in the previous version. To avoid this situation, we added the `overflow: hidden` style to the container. When the container height changes, the content is also hidden. You can override the style to modify this behavior:
```tsx
< Watermark style = {{ overflow: ' visible ' } } / >
```