Skip to content
API 风格:

Watermark ​

A watermark: each unit tile is generated offscreen as a dataURL by canvas and then tiled as a background image over the protected content (pointer-events:none + selection-proof). Two modes — text and image; on H5 a MutationObserver provides tamper-proof self-healing. The tile tiling computation (computeWatermarkTile) and the rendering checks all consume the pure logic in @lh-ui/share/core/watermark.

Basic Usage ​

Text watermark (multiple lines separated by \\n)

Protected content: drop in images, text or any business block.

The watermark overlays this area without blocking interaction.

vue
<script setup lang="ts">
import { LhWatermark } from '@lh-ui/vue3'
</script>

<template>
  <LhWatermark content="lh-ui family" :font-size="16" :gap-x="120">
    <div>Protected content</div>
  </LhWatermark>
</template>

Image watermark and fullscreen ​

image takes precedence over content; fullscreen covers the viewport (fixed positioning):

vue
<LhWatermark image="/logo.png" :opacity="0.2" fullscreen />

API ​

Watermark Props ​

PropDescriptionTypeDefault
contentWatermark text (multiple lines separated by \n); takes effect when image is not passedstring—
imageWatermark image URL; takes precedence over content when passedstring—
opacityOverall opacity (0-1)number0.15
rotateUnit tile rotation anglenumber-22
gapXHorizontal gap in pxnumber100
gapYVertical gap in px (falls back to gapX when not passed)number—
fontSizeText font size in px (falls back to the watermark.fontSize token when not passed)number14
fontColorText color (falls back to the color.text.primary token when not passed)string—
zIndexWatermark layer z-index (falls back to zIndex.normal when not passed)number100
fullscreentrue covers the full screen; false is absolutely positioned to the nearest positioned parentbooleanfalse
disabledTurn off the watermark (the watermark layer is not rendered)booleanfalse
sxsx quick-layout propsLhSxProps—

Watermark Slots ​

SlotDescription
defaultProtected content (the watermark overlays it)

Accessibility ​

The watermark layer is aria-hidden="true"; the root node has aria-label="Watermark".

Beauty of tradition, foundation of code