Text inputs
Capture short text reliably with visible labels, validation and helper text.
Live preview
We will use this address for account updates.
Use lowercase letters, numbers and hyphens.
HTML
<div class="xsh-stack" style="max-width:400px">
<div class="xsh-field">
<label for="xsh-example-email" class="xsh-label xsh-label--required">Work email</label>
<input id="xsh-example-email" class="xsh-input" type="email" placeholder="[email protected]" autocomplete="email" required>
<small class="xsh-help">We will use this address for account updates.</small>
</div>
<div class="xsh-field">
<label for="xsh-example-error" class="xsh-label">Team slug</label>
<input id="xsh-example-error" class="xsh-input" aria-invalid="true" aria-describedby="xsh-slug-error" value="invalid slug!">
<small id="xsh-slug-error" class="xsh-error">Use lowercase letters, numbers and hyphens.</small>
</div>
</div>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.
| Identifier | Contract |
|---|---|
xsh-field | Used by the example markup and component styles or behavior. |
xsh-label | Used by the example markup and component styles or behavior. |
xsh-input | Used by the example markup and component styles or behavior. |
xsh-input--sm | Used by the example markup and component styles or behavior. |
xsh-input--lg | Used by the example markup and component styles or behavior. |
xsh-help | Used by the example markup and component styles or behavior. |
xsh-error | Used by the example markup and component styles or behavior. |
Accessibility & keyboard
Pair each input with a native label. For errors set aria-invalid=true and connect the error text using aria-describedby.
Implementation note. Keep helper text visible and never use a placeholder in place of a label.
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.