Command palette

@yasinsensoy/web

Web · Components

Watermark

Watermark: tiles tilted, repeated text or a logo over the content.

4 exports

Live example

Preview

Q4 Finance Report

In the fourth quarter revenue grew 18% over the previous quarter. The biggest contribution came from business subscriptions; on the personal side the refund rate fell to 2.1%.

The goal for next quarter is to grow the sales team in new regions and renew the payment infrastructure. Detailed tables are attached.

Code

import { Watermark } from "@yasinsensoy/web";

<Watermark content={["CONFIDENTIAL","[email protected]"]}>
  <article>…</article>
</Watermark>

Events

  1. Events appear here when you interact with the preview.

Import

import { Watermark, getWatermarkStyle } from "@yasinsensoy/web";

Watermark

componentServer component

Watermark: tiles tilted, repeated text or a logo over the content. For a confidential document preview ("CONFIDENTIAL – [email protected]"), a draft page, a test environment, a photo preview before payment.

  • Server component: the pattern is generated as SVG and tiled with a CSS mask; no JavaScript, visible on the first paint.
  • Theme aware: the text color comes from CSS (color="var(--primary)"); it adapts automatically when the light/dark theme changes.
  • Doesn't block clicks: the layer is pointer-events: none; content below can be selected and clicked. Screen readers don't read the watermark.
  • Printing: visible in print too.
  • Protection: with protect a deleted or modified layer is restored.

To use it on your own element see getWatermarkStyle.

Watermark({ children, fullscreen, protect, zIndex, className, style, layerClassName, ...options }: WatermarkProps): JSX.Element

Examples

<Watermark content={["CONFIDENTIAL", user.email]}>
  <Report />
</Watermark>

<Watermark fullscreen content="TEST ENVIRONMENT" color="var(--destructive)" opacity={0.08} />
<Watermark image="/logo.svg" imageWidth={96} gap={[80, 80]}><img src={photo} alt="" /></Watermark>

Style of the watermark layer: to watermark any element (e.g. your own ::after layer or an image preview).

Text is drawn with a CSS mask; so its color changes with a theme variable and no JavaScript is needed. An image is tiled with its own colors.

getWatermarkStyle(options: WatermarkOptions): CSSProperties

Examples

<div className="absolute inset-0 pointer-events-none" style={getWatermarkStyle({ content: "DRAFT" })} />

Options of getWatermarkStyle (same as the Watermark props).

NameTypeDefaultDescription
content?string | readonly string[]Text; if an array is given each element is a separate line (e.g. ["CONFIDENTIAL", "[email protected]"]).
image?stringAn image (logo) instead of text. The image is tiled with its own colors and the opacity transparency.
imageWidth?number120Width of the image (px).
imageHeight?numberimageWidth` (square)Height of the image (px).
rotate?number-22Tilt (degrees).
gap?readonly [number, number][100, 100]Gap between patterns [horizontal, vertical] (px).
fontSize?number16Font size (px).
fontWeight?number | string500Font weight.
fontFamily?string"system-ui, sans-serif"Font family. Since it is drawn as an image, only system fonts can be used.
color?string"currentColor"Text color: any CSS color or theme variable (var(--primary)). Updates automatically when the theme changes.
opacity?number0.12Opacity (0–1).
stagger?booleantrueOffsets rows like bricks; the pattern looks less repetitive.

Props of the Watermark component.

NameTypeDefaultDescription
children?ReactNodeContent to watermark. Not needed with fullscreen.
fullscreen?booleanfalseCovers the whole screen (a fixed layer): confidential documents, test environment warning.
protect?booleanfalseIf the layer is deleted or its style changed with developer tools, it is restored (a small observer runs on the client).
zIndex?number10` (`50` with `fullscreen`)z-index of the layer.
className?stringClasses added to the container.
style?CSSPropertiesStyle of the container.
layerClassName?stringClasses added to the watermark layer.
content?string | readonly string[]Text; if an array is given each element is a separate line (e.g. ["CONFIDENTIAL", "[email protected]"]).
image?stringAn image (logo) instead of text. The image is tiled with its own colors and the opacity transparency.
imageWidth?number120Width of the image (px).
imageHeight?numberimageWidth` (square)Height of the image (px).
rotate?number-22Tilt (degrees).
gap?readonly [number, number][100, 100]Gap between patterns [horizontal, vertical] (px).
fontSize?number16Font size (px).
fontWeight?number | string500Font weight.
fontFamily?string"system-ui, sans-serif"Font family. Since it is drawn as an image, only system fonts can be used.
color?string"currentColor"Text color: any CSS color or theme variable (var(--primary)). Updates automatically when the theme changes.
opacity?number0.12Opacity (0–1).
stagger?booleantrueOffsets rows like bricks; the pattern looks less repetitive.