Back to Ant Design

Watermark

components/watermark/index.en-US.md

6.4.43.6 KB
Original Source

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> <code src="./demo/portal.tsx">Modal or Drawer</code> <code src="./demo/debug.tsx" debug>Table fixed columns</code>

API

Common props ref:Common props

This component is available since [email protected].

Watermark

PropertyDescriptionTypeDefaultVersionGlobal Config
widthThe width of the watermark, the default value of content is its own widthnumber120×
heightThe height of the watermark, the default value of content is its own heightnumber64×
inheritPass the watermark to the pop-up component such as Modal, Drawerbooleantrue5.11.0×
rotateWhen the watermark is drawn, the rotation Angle, unit °number-22×
zIndexThe z-index of the appended watermark elementnumber999×
imageImage source, it is recommended to export 2x or 3x image, high priority (support base64 format)string-×
contentWatermark text contentstring | string[]-×
fontText styleFontFont×
gapThe spacing between watermarks[number, number][100, 100]×
offsetThe 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]×
onRemoveCallback when the watermark is removed by DOM mutation() => void-6.0.0×

Font

<!-- prettier-ignore -->
PropertyDescriptionTypeDefaultVersion
colorfont colorCanvasFillStrokeStyles.fillStylergba(0,0,0,.15)
fontSizefont sizenumber16
fontWeightfont weightnormal | lighter | bold | bolder | numbernormal
fontFamilyfont familystringsans-serif
fontStylefont stylenone | normal | italic | obliquenormal
textAlignspecify the text alignment directionCanvasTextAligncenter5.10.0

Design Token

<ComponentTokenTable component="Watermark"></ComponentTokenTable>

FAQ

Handle abnormal image watermarks {#faq-invalid-image}

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
<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>

Why overflow: hidden style is added since version 5.18.0? {#faq-overflow-hidden}

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' }} />