Watermark
A watermark is a decorative repeating overlay text or image marking a page. The headless component exposes the props as data attributes and the right structural ARIA; the consumer implements the actual repeating pattern in CSS.
Use it for branding, draft markers, confidential overlays, or visual identifiers that span a page or region.
Implementation Notes
- Renders a
<div class="watermark">container withdata-rotateanddata-gapattributes - Inside the container, an overlay
<div class="watermark-overlay" aria-hidden="true">carriesdata-textanddata-image-url - The overlay is decorative and hidden from assistive tech
- Children render after the overlay
- Consumer is responsible for the actual repeating pattern (e.g., SVG-encoded background-image)
gapdefaults to"100px"androtatedefaults to-22
Props
text: string (optional) -- watermark textimageUrl: string (optional) -- watermark image URL (alternative to text)gap: string (default: "100px") -- spacing between repeats (CSS length)rotate: number (default: -22) -- rotation angle in degreeschildren: slot -- content beneath the watermark...restProps: any additional HTML attributes
Usage
<Watermark text="DRAFT" rotate={-22} gap="120px">
<article>...</article>
</Watermark>
<Watermark imageUrl="/brand.svg" rotate={0} gap="200px">
<main>...</main>
</Watermark>
Keyboard Interactions
- None — purely decorative.
ARIA
- The watermark overlay has
aria-hidden="true"so screen readers ignore it - The container itself has no role
- Underlying content remains fully accessible
When to Use
- Use for visible-but-decorative branding or status markers (DRAFT, CONFIDENTIAL).
- Use when the watermark must repeat across a region of the page.
When Not to Use
- Do not use for content that screen readers must announce — that content belongs in the document flow.
- Do not use as a privacy or security control — watermarks are visual only.
Headless
Renders only the structural markup and exposes props as data attributes. The consumer implements the repeating background pattern (e.g., a background-image that uses an SVG generated from data-text) and any animation, opacity, or color treatment.
Styles
Consumer CSS targets watermark and watermark-overlay. Use a CSS gradient or repeating background-image to implement the pattern; consume data-rotate and data-gap via attribute selectors or custom properties.
Testing
- Verify the component renders a
<div>element with classwatermark - Verify
data-rotatereflects therotateprop (default -22) - Verify
data-gapreflects thegapprop (default "100px") - Verify the inner
<div class="watermark-overlay">hasaria-hidden="true" - Verify
data-textis set on the overlay whentextis provided - Verify
data-image-urlis set on the overlay whenimageUrlis provided - Verify children render after the overlay element
Advice
- Designers: Choose a low-contrast watermark so it does not interfere with reading. Test at small and large viewports.
- Developers: Encode the watermark as an inline SVG background-image for crisp rendering. Use the data attributes to drive the CSS.
Related components
banner— a prominent message bar across the top of a pageimage— an image element with alt text
References
- WAI-ARIA aria-hidden: https://www.w3.org/TR/wai-aria-1.2/#aria-hidden
- Ant Design Watermark: https://ant.design/components/watermark