Your details
Checked by the server. Try “Acme”.
To confirm the account.
- Frames
- 0
- Active effects
- 0
- Renderer
- none
input.ts
import "@shader-ui/core/styles.css";
import { TYPING_PAUSE, watchField } from "@shader-ui/core";
const isTaken = (name: string) =>
new Promise<boolean>((resolve) => setTimeout(() => resolve(name === "acme"), 900));
document.body.insertAdjacentHTML(
"beforeend",
`<label for="org">Organisation (try “Acme”)</label>
<input id="org" autocomplete="organization" required aria-describedby="org-hint">
<p id="org-hint" aria-live="polite"></p>
<label for="email">Email</label>
<input id="email" type="email" autocomplete="email" required aria-describedby="email-hint">
<p id="email-hint">To confirm the account.</p>`,
);
const org = document.querySelector<HTMLInputElement>("#org")!;
const orgHint = document.querySelector("#org-hint")!;
const email = document.querySelector<HTMLInputElement>("#email")!;
watchField(org);
watchField(email);
let pause: ReturnType<typeof setTimeout>;
org.addEventListener("input", () => {
clearTimeout(pause);
pause = setTimeout(async () => {
org.setAttribute("aria-busy", "true");
orgHint.textContent = "Checking…";
const taken = await isTaken(org.value.trim().toLowerCase());
org.removeAttribute("aria-busy");
orgHint.textContent = taken ? "This name is already in use." : "This name is available.";
if (taken) org.setAttribute("aria-invalid", "true");
else org.removeAttribute("aria-invalid");
}, TYPING_PAUSE);
});SignupFields.tsx
import { Input, TYPING_PAUSE } from "@shader-ui/react";
import { useRef, useState } from "react";
const isTaken = (name: string) =>
new Promise<boolean>((resolve) => setTimeout(() => resolve(name === "acme"), 900));
export function SignupFields() {
const [checking, setChecking] = useState(false);
const [taken, setTaken] = useState(false);
const pause = useRef<ReturnType<typeof setTimeout>>(undefined);
const check = (name: string) => {
clearTimeout(pause.current);
pause.current = setTimeout(async () => {
setChecking(true);
setTaken(await isTaken(name.trim().toLowerCase()));
setChecking(false);
}, TYPING_PAUSE);
};
return (
<>
<label htmlFor="org">Organisation (try “Acme”)</label>
<Input
id="org"
autoComplete="organization"
required
aria-busy={checking || undefined}
aria-invalid={taken || undefined}
aria-describedby="org-hint"
onChange={(e) => check(e.target.value)}
/>
<p id="org-hint" aria-live="polite">
{checking ? "Checking…" : taken ? "This name is already in use." : ""}
</p>
<label htmlFor="email">Email</label>
<Input id="email" type="email" autoComplete="email" required aria-describedby="email-hint" />
<p id="email-hint">To confirm the account.</p>
</>
);
}When to use it
- For short, free entry: name, email, password, code, date.
- Not for long text (Textarea, coming soon), nor for picking among options: use a checkbox or radio buttons.
Recommendations
- Server check (name already taken, promo code): set aria-busy while waiting, and keep aria-invalid until the new answer. Removing the error on typing would turn the field green before the server has confirmed.
- Start the check after the same typing pause as the library (TYPING_PAUSE, 1 s), or when leaving the field.
Accessibility
The library
- Native <input> element: keyboard, autofill, screen readers, ref and react-hook-form work as usual.
- An error is not shown by color alone: thicker border and diode, with 3:1 contrast.
- Visible focus at 3:1, without the shader. Text of at least 16 px, height of at least 44 px.
- While loading, the orbit stops after 5 s; the diode stays steady.
- Reduced motion: a simple fade. High contrast: system colors, no shader.
Integration
- A visible label, tied to the field. Without a label, no "required" glow.
- An error text, tied with aria-describedby or aria-errormessage: light doubles it, never replaces it.
- A server response announced with aria-live.
WCAG 2.2 criteria: Use of Color · Non-text Contrast · Pause, Stop, Hide · Animation from Interactions · Focus Visible · Error Identification · Labels or Instructions · Status Messages
Props
| Prop | Type | Purpose |
|---|---|---|
required, type, pattern… | HTML | Native validity: read by the library, after interaction. |
aria-invalid | boolean | Error set by your validation (Zod, react-hook-form) or the server. |
aria-busy | boolean | Check in progress: violet orbit, steady diode after 5 s. |
effects | { onPaste: "ripple" } | Effects triggered by DOM events. |
onEffectEnd | (e) => void | Always called, even when the effect is skipped. |
ref | ShaderElement<HTMLInputElement> | The native element, plus trigger(). |
Spec
The normative spec for this component: Formulaire
Availability and resources
- Status
- available · open source
- Packages
- @shader-ui/react (React, Next.js)
@shader-ui/core (TypeScript, plain HTML)