<secure-textarea>
A security-hardened multi-line text input with content sanitization, length enforcement, and XSS prevention.
Overview
The <secure-textarea> component provides a multi-line text input with automatic content sanitization. All HTML tags are escaped, scripts are stripped, and length limits are enforced based on security tier.
Basic Usage
Simple Textarea HTML
<secure-textarea
label="Biography"
name="bio"
rows="4"
placeholder="Tell us about yourself..."
security-tier="public"
maxlength="1000"
></secure-textarea>Live Demo
Security Tiers
Different Security Levels HTML
<!-- PUBLIC: Comments, descriptions -->
<secure-textarea
security-tier="public"
label="Comments"
name="comments"
rows="3"
></secure-textarea>
<!-- SENSITIVE: Personal notes -->
<secure-textarea
security-tier="sensitive"
label="Medical Notes"
name="medical_notes"
rows="5"
></secure-textarea>
<!-- CRITICAL: Highly sensitive content -->
<secure-textarea
security-tier="critical"
label="Confidential Notes"
name="confidential_notes"
rows="6"
></secure-textarea>Threat Feedback
Add threat-feedback to show an inline amber warning when an injection pattern is detected. This attribute is opt-in by design: <secure-textarea> is often used in fields where injection-like syntax is legitimate input — markdown, code snippets, HTML templates, configuration files. Apply it only where the field is not expected to receive such content.
Correct Usage HTML
<!-- Contact form message: threat feedback appropriate -->
<secure-textarea
label="Message"
name="message"
security-tier="public"
threat-feedback>
</secure-textarea>
<!-- Code editor field: threat feedback NOT appropriate -->
<secure-textarea
label="HTML Template"
name="template_code"
security-tier="public">
</secure-textarea>Silent detection still applies
Omitting
threat-feedback does not disable injection scanning. The secure-threat-detected event fires on every match regardless, so server-side telemetry and audit logging are unaffected. Only the inline UI is suppressed.API Reference
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
security-tier | string | "critical" | Security level |
name | string | - | Form field name |
label | string | - | Accessible label |
rows | number | 3 | Visible text lines |
cols | number | - | Visible character width |
minlength | number | - | Minimum characters |
maxlength | number | - | Maximum characters |
placeholder | string | - | Placeholder text |
required | boolean | false | Field is required |
disabled | boolean | false | Disable textarea |
readonly | boolean | false | Read-only mode |
threat-feedback | boolean | false | Show inline amber warning when an injection pattern is detected. Opt-in — omit on fields that legitimately accept markup, code, or template syntax. |
Properties
value string Get or set the textarea content
valid boolean Validation state
Methods
focus(): void
Focus the textarea element
blur(): void
Remove focus from the textarea element
getAuditLog(): AuditLogEntry[]
Returns the component's audit log entries
getFieldTelemetry(): FieldTelemetry
Returns behavioral signals: dwell, velocity, corrections, paste/autofill detection, focus metrics
reportError(message: string, variant?: 'error' | 'warning'): void
Display an external validation message on this field. Default variant is
'error'.clearExternalError(): void
Clear a message previously set by
reportError()Events
| Event | Detail | Description |
|---|---|---|
secure-textarea-change | { name, tier } | Fired on every content change. value is intentionally absent — read (e.target as SecureTextarea).value directly. |
secure-audit | { event, tier, timestamp, data? } | Fired on every audit entry |
secure-threat-detected | { fieldName, threatType, patternId, tier, timestamp } | Fired when an injection pattern matches. Raw value intentionally absent. Fires regardless of threat-feedback attribute. |