Skip to content

Watermark

Add a watermark to specific areas of a page. Features strong anti-removal and anti-tamper capabilities.

Basic Usage

Basic content display

Business Scenario: Form Data Protection

When handling forms with confidential information like names and salaries, watermarks serve as a critical security layer.

Employee Sensitive Data Preview

Account: user_admin_01
Name: Wang Xiaoming
Phone: 138****8888
Level: P7 - Senior Engineer
Salary: ¥**,000 (A)
Dept: Frontend Intelligent Dept

Fullscreen Watermark

Interactive Configuration

Explore advanced configurations in real-time using the lab below.

Build modern, fast, and flagship-level Vue 3 component libraries

z-index: 5

Core Asset Protection

Here you can customize the watermark deeply. When z-index < 5, the watermark text will hide behind the blue card, achieving differentiated protection for page elements.

normal
center

Usage in Nuxt

Since the Watermark component relies on DOM operations and Canvas rendering, ensure you wrap it with a <ClientOnly> tag in SSR environments like Nuxt 3.

vue
<template>
  <ClientOnly>
    <yh-watermark content="YH-UI Nuxt Powered">
      <div style="height: 300px;">Content Area</div>
    </yh-watermark>
  </ClientOnly>
</template>

API

Props

NameDescriptionTypeDefault
widthWidth of each watermark unitnumber120
heightHeight of each watermark unitnumber64
rotateRotation angle of the unit cellnumber-22
globalRotateOverall rotation anglenumber0
zIndexWatermark z-indexnumber9
imageImage source; if set, content will be ignoredstring-
contentWatermark text; supports multi-linestring | string[]'YH-UI'
fontFont style configuration objectFontSee below
gapGap between watermarks [x, y][number, number][100, 100]
offsetOffset from the container's start point [x, y][number, number][0, 0]
fullScreenWhether to mount the watermark under body for fullscreenbooleanfalse
antiTamperWhether to enable anti-tamper mode (monitors DOM changes)booleantrue

Font Object Description

NameDescriptionTypeDefault
colorText colorstring`'rgba(0,0,0,0.15)'
fontSizeFont sizenumber | string16
fontWeightFont weightstring | number'normal'
fontFamilyFont familystring'sans-serif'
fontStyleFont style'normal' | 'italic' | 'oblique''normal'
textAlignText alignment'start' | 'end' | 'left' | 'right' | 'center''center'
lineHeightLine heightnumber22

Events

This Watermark component does not currently expose any events.

Slots

NameDescription
defaultContent area covered by the watermark

Expose

NameDescriptionType
renderWatermarkForce a re-render of the watermark (useful when container size changes but isn't detected)() => void

Theme Variables (CSS Variables)

Define basic styles using these CSS variables; they can be overridden locally or globally.

Variable NameDescriptionDefault
--yh-watermark-container-positionPositioning mode for the wrapper containerrelative
--yh-watermark-widthComponent width100%
--yh-watermark-heightComponent height100%
--yh-watermark-fullscreen-z-indexForced z-index in fullscreen mode9999

Released under the MIT License.