Redact
Redact is an agent-native component that blurs and protects sensitive content in the slot (secrets, tokens, salaries, PII) until an explicit reveal by click, hover, or programmatic call. While hidden, the accessibility tree exposes only a generic label ("hidden content"), so screen readers and agents never leak the real value before a human reveals it. The agent-native layer mirrors the state in stable data-* attributes on the host (data-pura-redact, data-pura-id, data-state, data-reveal-on) and registers each instance in window.__puraRedactions, letting agents audit and control every redaction on the page without crossing the Shadow DOM (the value is never mirrored in those attributes).
Preview
<p style="font-family: system-ui; line-height: 2;">
Your API key:
<pura-redact id="apikey" reveal-on="click" toggle blur="md">sk-live-9f2c7b41ad8e4f00</pura-redact>
<br>
Salary (hover over it):
<pura-redact reveal-on="hover" blur="lg">$14,250.00</pura-redact>
</p>
<p id="status" style="font-family: system-ui; color: #16a34a; font-size: 14px;"></p>
<script type="module">
const status = document.getElementById("status");
document.getElementById("apikey").addEventListener("reveal", (e) => {
status.textContent = "Key revealed: " + e.detail.value;
});
document.getElementById("apikey").addEventListener("hide", () => {
status.textContent = "Key hidden again.";
});
</script> Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
reveal-on | "click" | "hover" | "none" | click | Interaction that reveals the content. "none" makes it purely programmatic (reveal via .reveal()). |
revealed | boolean | false | Reflected boolean; present while the value is visible. Set it in markup to start already revealed. |
label | string | conteúdo oculto | Accessible label announced while the content is hidden. |
blur | "sm" | "md" | "lg" | md | Intensity of the blur that obscures the content while hidden. |
toggle | boolean | false | When present, the same interaction that reveals also hides again (click toggles). |
disabled | boolean | false | Non-interactive; stays hidden and cannot be revealed by the user. |
Installation
pura is copy-paste and dependency-free. Load the whole library, or just this component.
<link rel="stylesheet" href="/pura/tokens.css">
<script type="module" src="/pura/lib/redact.js"></script> import "./pura/lib/redact.js";