Watermark
Headless Watermark; covers Ant Design Watermark, shadcn/ui.
| Package | @vizejs/ui/watermark |
| Maturity | stable |
| Quality gates | behavior contract, mounted dom, type inference, tree shaking, bundle size, ssr, hydration, dom compile, ssr compile, vapor compile |
| Bundle budget | 4,000 B JS gzip / 0 B CSS gzip |
| Own the source | vize lib pull watermark |
| Requires | — |
| Aliases | stamp, repeated label, draft overlay |
| Covers | Ant Design Watermark, shadcn/ui |
Minimal setup
Use a Vue 3.5+ project with Vue SFC compilation configured (see Vite+ integration).
vp install @vizejs/ui
Add the public import below to <script setup lang="ts">. Components provide behavior without styles; the preview uses optional Paper styles.
import { Watermark } from "@vizejs/ui/watermark";
Or copy the source into your project with vize lib pull watermark (see Source Distribution).
Try it
This is the basic example maintained with the component source, using the public package imports. The preview adds the optional Paper styles.
Open the interactive example · Styling these components
Copy the example
<!-- Draft watermark over a button that must stay clickable. -->
<script setup lang="ts">
import { ref } from "vue";
import { Watermark } from "@vizejs/ui/watermark";
const published = ref(0);
</script>
<template>
<Watermark text="DRAFT" :opacity="0.2">
<button type="button" @click="published += 1">Publish {{ published }}</button>
</Watermark>
</template>
Stamp the page without blocking it
Watermark repeats text in an SVG data URI. The overlay is aria-hidden and
pointer-events: none, so the slot stays clickable and is not read twice.
The image is built during setup, including on the server, and does not measure
the document.
<script setup lang="ts">
import { Watermark } from "@vizejs/ui/watermark";
</script>
<template>
<Watermark text="DRAFT">
<button type="button">Publish</button>
</Watermark>
</template>
text is escaped. < in the label cannot break out of the SVG. gap is the
tile size and rotate is the clockwise angle of each tile.
API
Watermark
Source: src/components/watermark/watermark.vue
Props
| Prop | Type | Default | Description |
|---|---|---|---|
text |
string |
"" |
Text repeated across the overlay. Markup is escaped. |
opacity |
number |
0.15 |
Opacity of the overlay, from 0 to 1. The slotted content stays opaque. |
gap |
number |
160 |
Tile size in CSS pixels. |
rotate |
number |
-24 |
Clockwise rotation of each tile, in degrees. |
Slots
| Slot | Slot props | Description |
|---|---|---|
default |
— | Content that stays interactive underneath the overlay. |
Behavior
Normative state × input → outcome table for src/components/watermark/watermark.vue.
Every row is proven by src/components/watermark/tests/behavior.test.ts.
| # | State | Input | Outcome | Proven by |
|---|---|---|---|---|
| W1 | text DRAFT |
render | overlay is aria-hidden, ignores pointers, and exposes the SVG tile on data-image |
repeats text in an inert overlay |
| W2 | slotted button | click | the button remains a button and receives the click | keeps slotted controls interactive |
| W3 | text A&B<C> |
format | markup is escaped before it enters the SVG | escapes markup before building the image |