Watermark
Overlay repetitive text or image watermark layers onto host containers. Designed with security precautions, the component intercepts style changes (e.g. display: none) or physical DOM node removal, automatically reconstructing pure watermark nodes in real-time.
Preview
基础文本水印 (全区域铺满)
机密合同内容详情
本协议及其附件所含全部技术信息、商业机密和规划均属甲乙双方的核心资产。未经双方共同书面授权,严禁任何第三方以任何形式进行复制、分发或传播。
旋转度数与网格间距定制
红色醒目警告水印
此处平铺的是红色倾斜的 Confidential 英文防篡改水印,间距加宽为 100x100 像素网格,多层防护。
Installation
pnpm dlx brutx-vue@latest add watermarkUsage
Basic Text Watermark
Wrap sensitive content within <Watermark>.
<script setup>
import { Watermark } from 'brutx-ui-vue'
</script>
<template>
<Watermark content="CONFIDENTIAL INFO">
<div class="confidential-doc">
<h3>Internal Documents</h3>
<p>Agreement details...</p>
</div>
</Watermark>
</template>Multi-line & Styling Customization
Pass an array to render multi-line text, and customize font sizing, angles, and gap grids.
<template>
<Watermark
:content="['CONFIDENTIAL', 'DEPT 01']"
:rotate="-15"
:gap="[120, 120]"
:font="{ color: 'rgba(239, 68, 68, 0.12)', fontSize: 16, fontWeight: 'bold' }"
>
<div class="content-box">
<p>Sensitive data details...</p>
</div>
</Watermark>
</template>API Reference
| Name | Type | Default | Description |
|---|---|---|---|
width | number | undefined | 120 | Sets the width in pixels of a single watermark tile. |
DetailsDeclared typenumber | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
height | number | undefined | 64 | Sets the height in pixels of a single watermark tile. |
DetailsDeclared typenumber | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
rotate | number | undefined | -22 | Sets the watermark rotation in degrees; the default -22 tilts it counterclockwise. |
DetailsDeclared typenumber | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
zIndex | number | undefined | 9999 | Sets the CSS z-index of the watermark overlay. |
DetailsDeclared typenumber | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
image | string | undefined | undefined | Sets a watermark image URL or Data URL. When provided, the image is used instead of text content. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
content | string | string[] | undefined | "" | Sets the watermark text. A string array lays out multiple lines in a tile. |
DetailsDeclared typestring | string[] | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
font | WatermarkFont | undefined | { "fontFamily": "sans-serif", "fontSize": 14, "fontStyle": "normal", "fontWeight": "normal" }Factory evaluated per instance | Configures text watermark color, size, weight, style, and family. By default it uses 14px sans-serif with normal weight and draws --brutal-fg at 15% opacity. |
DetailsDeclared typeWatermarkFont | undefined Referenced types WatermarkFont Type definition — WatermarkFontinterface WatermarkFont {
color?: string
fontSize?: number | string
fontWeight?: 'normal' | 'light' | 'weight' | 'bold' | number
fontStyle?: 'normal' | 'italic' | 'oblique'
fontFamily?: string
}Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
gap | [number, number] | undefined | [100, 100]Factory evaluated per instance | Sets horizontal and vertical spacing between watermark tiles as [gapX, gapY]. |
DetailsDeclared type[number, number] | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
offset | [number, number] | undefined | [0, 0]Factory evaluated per instance | Offsets the starting point of the watermark tiling horizontally and vertically as [offsetX, offsetY]. |
DetailsDeclared type[number, number] | undefined Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
seal | boolean | undefined | false | Adds a vintage seal treatment with two circular rings and a centered five-point star in each tile. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/watermark/Watermark.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | The host content covered by the watermark; the component tiles the decorative watermark over it. |
DetailsDeclared type{}Sourcepackages/ui/src/components/watermark/Watermark.vue | ||
WatermarkFont Type Definitions
interface WatermarkFont {
color?: string // Color, defaults to 'rgba(0, 0, 0, 0.15)'
fontSize?: number | string // Font size, supports numbers or units like '16px', '1.2rem', defaults to 14
fontWeight?: 'normal' | 'light' | 'weight' | 'bold' | number // Font weight, defaults to 'normal'
fontStyle?: 'normal' | 'italic' | 'oblique' // Font style, defaults to 'normal'
fontFamily?: string // Font family, defaults to 'sans-serif'
}Security Features
- JSDOM SVG Fallback: Automatically switches to drawing pure inline vector SVG watermarks if the renderer fails to initialize 2D Canvas contexts (e.g. under headless test setups), maintaining page structure validity.
- Anti-tamper Guard: Listens to changes using
MutationObserveron the target nodes. Any external tampering of style strings or DOM element deletion will be reverted, rebuilding a pristine watermark layout inside 50ms.
Accessibility
- Decorative layer: The watermark is a decorative background layer and does not carry semantic content; pair it with
aria-hiddenandpointer-events-noneso it is not announced by assistive technology and does not intercept pointer events. - Contrast: Watermark text color tokens should keep reasonable contrast against the background, but as a decorative layer it is not required to meet WCAG text-contrast thresholds.
- Reduced motion: Tamper-guard rebuild and Canvas drawing introduce no forced motion and respect
prefers-reduced-motion.