Watermark
Watermark: the unit tile is rendered offscreen to a canvas dataURL and tiled as a
background over the protected content (pointer-events: none, not selectable).
Text and image modes; H5 carries a MutationObserver self-healing guard.
Basic usage
Text watermark (multi-line via \n)
受保护的内容:水印叠加在本区域之上,不阻断交互。
disabled:不渲染水印层。
import { LhWatermark } from '@lh-ui/react'
export default function Demo() {
return (
<LhWatermark content="lh-ui 家族" fontSize={16} gapX={120}>
<div>Protected content</div>
</LhWatermark>
)
}
Image watermark & fullscreen
image takes precedence over content; fullscreen covers the viewport
(fixed position):
<LhWatermark image="/logo.png" opacity={0.2} fullscreen />
Watermark API
| Prop | Description | Type | Default |
|---|---|---|---|
| content | Watermark text (multi-line via \n; used when image is absent) | string | — |
| image | Watermark image URL; takes precedence over content | string | — |
| opacity | Layer opacity (0-1) | number | 0.15 |
| rotate | Unit tile rotation (deg) | number | -22 |
| gapX | Horizontal gap px | number | 100 |
| gapY | Vertical gap px (falls back to gapX) | number | — |
| fontSize | Text size px (falls back to watermark.fontSize token) | number | 14 |
| fontColor | Text color (falls back to color.text.primary token) | string | — |
| zIndex | Layer z-index (falls back to zIndex.normal) | number | 100 |
| fullscreen | Cover the viewport instead of the positioned parent | boolean | false |
| disabled | Turn the watermark off (no layer rendered) | boolean | false |
| sx | Quick layout props | LhSxProps | — |
| children | Protected content (plus default slot) | ReactNode | — |