xxshna.ui
V 1.1.0Get started ↗

Form validation

Show explicit feedback for required fields and submission errors.

Catalog · 1.1HTML, CSS & optional JSNo runtime dependencies

Live preview

Interactive exampleOpen playground ↗
At least two characters.
HTML
<form class="xsh-stack" style="max-width:420px;width:100%" data-xsh-demo-form>
<div class="xsh-field">
<label class="xsh-label xsh-label--required" for="xsh-demo-user">Your name</label>
<input class="xsh-input" id="xsh-demo-user" name="name" required minlength="2" placeholder="Full name">
<span class="xsh-help">At least two characters.</span>
</div>
<div class="xsh-field">
<label class="xsh-label xsh-label--required" for="xsh-demo-mail">Email address</label>
<input class="xsh-input" id="xsh-demo-mail" name="email" type="email" required placeholder="[email protected]">
</div>
<button class="xsh-button" type="submit">Validate and submit</button>
</form>

Installation & markup

Include the local stylesheet and script once on the page, then place the component inside a data-xsh-ui root. The example above works without a build system.

<link rel="stylesheet" href="/dist/xshna-ui.css">
<div data-xsh-ui>
  <!-- Add the HTML example above -->
</div>
<script defer src="/dist/xshna-ui.js"></script>

Component API

Public classes, attributes and hooks used by this example. Keep the xsh- prefix intact.

IdentifierContract
xsh-inputUsed by the example markup and component styles or behavior.
xsh-labelUsed by the example markup and component styles or behavior.
xsh-errorUsed by the example markup and component styles or behavior.
requiredUsed by the example markup and component styles or behavior.
aria-invalidUsed by the example markup and component styles or behavior.
aria-describedbyUsed by the example markup and component styles or behavior.

Accessibility & keyboard

Uses HTML constraint validation (required, minlength and email). The browser announces invalid controls; valid example submissions show a toast.

Implementation note. Always repeat validation and authorization on the server. A client-side demo never replaces backend validation.

Interaction contract

Behavioral components use the shared delegated runtime; visual-only primitives rely on semantic HTML and CSS. Runtime controls emit bubbling xsh:* CustomEvents; bind application handlers to those events when server persistence, API data or navigation is required.