Skip to content

Watermark - Vant 4

Watermark ​

Intro ​

Add specific text or patterns on the page as watermarks, which can be used to prevent information theft. Please upgrade vant to >= v4.2.0 before using this component.

Install ​

Register component globally via app.use, refer to Component Registration for more registration ways.

js
import { createApp } from'vue'; import { Watermark } from'vant'; const app = createApp(); app.use(Watermark);

Usage ​

Text Watermark ​

Use the content prop to set the text of the watermark.

html

Image Watermark ​

Use the image prop to set the watermark image, and use opacity prop to adjust the transparency of the watermark.

html

Custom Gap ​

Use gap-x``gap-y prop to control the gap between watermark items.

html

Custom Rotate ​

Use rotate prop to control the rotate of watermark. The default value is -22.

html

Display Range ​

Use the full-page prop to control the display range of the watermark.

html

HTML Watermark ​

Use the content slot to pass HTML as watermark. Only supports inline styles, and self-closing tags are not supported.

html

API ​

Props ​

AttributeDescriptionTypeDefault
widthWatermark widthnumber100
heightWatermark heightnumber100
z-indexWatermark's z-index*numberstring*
contentText watermark contentstring-
imageImage watermark content. If content and image are passed at the same time, use the image watermark firststring-
rotateWatermark rotation angle*numberstring*
full-pageWhether to display the watermark in full screenbooleantrue
gap-xHorizontal spacing between watermarksnumber0
gap-yVertical spacing between watermarksnumber0
text-colorColor of text watermarkstring#dcdee0

| opacity | Opacity of watermark | number | string | - |

Slots ​

AttributeDescription
contentContent of HTML watermark. Only supports inline styles, and self-closing tags are not supported. The priority is higher than content or image props

Types ​

The component exports the following type definitions:

ts
importtype { WaterProps } from'vant';

Theming ​

CSS Variables ​

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

NameDefault ValueDescription
--van-watermark-z-index100z-index of root element

Enterprise-level mobile solution based on Vant