Skip to content

Watermark

Add a watermark to a specific area of the page. It supports text or image watermarks, fullscreen overlays, and anti-tamper regeneration.

Basic Usage

Basic content display

Business Scenario: Form Data Protection

For pages that display sensitive content, YhWatermark can be added directly around the protected area without changing the internal layout.

Employee Sensitive Data Preview

Account: user_admin_01
Name: Wang Xiaoming
Phone: 138****8888
Level: P7 - Senior Engineer
Salary: 32,000 CNY / month
Dept: Frontend Intelligence Dept

Fullscreen Watermark

Use full-screen when the watermark should cover the whole viewport instead of a local container.

Interactive Configuration

The following lab keeps the existing preview layout and lets you inspect the effect of font, gap, rotation, and z-index changes in real time.

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

Use in Nuxt

YhWatermark is safe to import in Nuxt. The container markup can be rendered during SSR, while the actual watermark drawing runs on the client after mount. If you want to avoid rendering the watermark container before hydration in a browser-only area, you can wrap it with <ClientOnly>.

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 tilenumber120
heightHeight of each watermark tilenumber64
rotateRotation angle of each watermark tilenumber-22
z-indexz-index applied to the watermark overlaynumber9
imageImage source used instead of text contentstringundefined
contentWatermark text content. Strings can include line breaks and arrays map to multiple lines.string | string[]'YH-UI'
fontWatermark font configurationYhWatermarkFontsee below
global-rotateGlobal rotation angle of the repeated watermark layernumber0
gapHorizontal and vertical gap between watermark tiles[number, number][100, 100]
offsetDeclared offset prop. The current implementation does not consume it when positioning the watermark layer[number, number][0, 0]
full-screenUses a fixed-position wrapper to cover the viewport. The component is not teleported to bodybooleanfalse
anti-tamperRebuilds the watermark when the overlay is removed or modifiedbooleantrue
theme-overridesComponent-level theme overrides. In the current implementation they are merged only in non-fullscreen modeComponentThemeVarsundefined

Font

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 inside the watermark tile'start' | 'end' | 'left' | 'right' | 'center''center'
lineHeightLine height for multi-line textnumber22

Events

This component does not expose component events.

Slots

NameDescriptionParameters
defaultContent covered by the watermark overlay-

Expose

NameDescriptionType
renderWatermarkForces the watermark to be regenerated() => void

Theme Variables

YhWatermark supports themeOverrides and also exposes a small wrapper-level CSS variable surface.

VariableDescriptionDefault
--yh-watermark-container-positionPosition mode of the watermark wrapperrelative
--yh-watermark-widthWrapper width100%
--yh-watermark-heightWrapper height100%
--yh-watermark-fullscreen-z-indexFullscreen wrapper z-index9999

Type Exports

NameDescription
YhWatermarkPropsComponent props type
YhWatermarkFontWatermark font config type
YhWatermarkSlotsComponent slots type
YhWatermarkExposeComponent expose type
YhWatermarkInstanceComponent instance type

Released under the MIT License.