Use cases
Real situations, and what light says in them. Each demo is live: try it.
Create an account
An organisation name checked by the server, an email, terms to accept.
What lights up
- On first interaction, a glow after each required field: what is left to fill in.
- While the name is checked, the violet orbit: the server is working.
- Name already in use: coral pulse when leaving the field, never while typing.
- Fixed and confirmed: a green sweep, and the diode stays green.
- Frames
- 0
- Active effects
- 0
- Renderer
- none
account.ts
import "@shader-ui/core/styles.css";
import { TYPING_PAUSE, watchForm } from "@shader-ui/core";
const isTaken = (name: string) =>
new Promise<boolean>((resolve) => setTimeout(() => resolve(name === "acme"), 900));
const createAccount = () => new Promise<void>((resolve) => setTimeout(resolve, 1600));
document.body.insertAdjacentHTML(
"beforeend",
`<form id="account">
<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>
<label><input type="checkbox" required> I accept the terms of use</label>
<button type="submit">Create account</button>
</form>`,
);
const form = document.querySelector<HTMLFormElement>("#account")!;
const org = document.querySelector<HTMLInputElement>("#org")!;
const orgHint = document.querySelector("#org-hint")!;
watchForm(form, {
guide: true,
onSubmit: (event) => {
event.preventDefault();
if (org.getAttribute("aria-invalid") === "true") return;
return createAccount();
},
});
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);
});CreateAccount.tsx
import { Button, Checkbox, Form, 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));
const createAccount = () => new Promise<void>((resolve) => setTimeout(resolve, 1600));
export function CreateAccount() {
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 (
<Form
guide
onSubmit={(e) => {
e.preventDefault();
if (taken) return;
return createAccount();
}}
>
<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>
<label>
<Checkbox required /> I accept the terms of use
</label>
<Button type="submit">Create account</Button>
</Form>
);
}Place an order
A name, an address, a delivery method, the terms of sale, then payment.
What lights up
- Paying before filling everything in: errors pulse one after another, in form order. You see every error in a single wave.
- Everything is filled in: the button pulses once, “you can go”, even if you have to scroll down to it.
- During payment, the button carries the orbit and its diode; a second click is ignored, without disabling the button.
- Frames
- 0
- Active effects
- 0
- Renderer
- none
form.ts
import "@shader-ui/core/styles.css";
import { watchForm } from "@shader-ui/core";
const pay = () => new Promise<void>((resolve) => setTimeout(resolve, 1400));
document.body.insertAdjacentHTML(
"beforeend",
`<form id="order">
<label for="name">Full name</label>
<input id="name" autocomplete="name" required>
<label for="address">Delivery address</label>
<input id="address" autocomplete="street-address" required>
<fieldset>
<legend>Delivery</legend>
<label><input type="radio" name="delivery" value="standard" required> Standard, free</label>
<label><input type="radio" name="delivery" value="express" required> Express, €9.90</label>
</fieldset>
<label><input type="checkbox" required> I accept the terms of sale</label>
<button type="submit">Pay €49.00</button>
</form>`,
);
watchForm(document.querySelector<HTMLFormElement>("#order")!, {
guide: true,
onSubmit: (event) => {
event.preventDefault();
return pay();
},
});Order.tsx
import { Button, Checkbox, Form, Input, Radio } from "@shader-ui/react";
const pay = () => new Promise<void>((resolve) => setTimeout(resolve, 1400));
export function Order() {
return (
<Form
guide
onSubmit={(e) => {
e.preventDefault();
return pay();
}}
>
<label htmlFor="name">Full name</label>
<Input id="name" autoComplete="name" required />
<label htmlFor="address">Delivery address</label>
<Input id="address" autoComplete="street-address" required />
<fieldset>
<legend>Delivery</legend>
<label>
<Radio name="delivery" value="standard" required /> Standard, free
</label>
<label>
<Radio name="delivery" value="express" required /> Express, €9.90
</label>
</fieldset>
<label>
<Checkbox required /> I accept the terms of sale
</label>
<Button type="submit">Pay €49.00</Button>
</Form>
);
}Subscribe to a newsletter
Optional topics, and a privacy policy to accept.
What lights up
- A ticked optional box lights up white: a choice.
- The ticked required box does a small green sweep, then stays green: what was required is done.
- Frames
- 0
- Active effects
- 0
- Renderer
- none
checkbox.ts
import "@shader-ui/core/styles.css";
import { watchForm } from "@shader-ui/core";
const subscribe = () => new Promise<void>((resolve) => setTimeout(resolve, 1400));
document.body.insertAdjacentHTML(
"beforeend",
`<form id="newsletter">
<fieldset>
<legend>Topics (optional)</legend>
<label><input type="checkbox" name="topics" value="news"> Library news</label>
<label><input type="checkbox" name="topics" value="a11y"> Accessibility articles</label>
</fieldset>
<label><input type="checkbox" required> I accept the privacy policy</label>
<button type="submit">Subscribe</button>
</form>`,
);
watchForm(document.querySelector<HTMLFormElement>("#newsletter")!, {
guide: true,
onSubmit: (event) => {
event.preventDefault();
return subscribe();
},
});Newsletter.tsx
import { Button, Checkbox, Form } from "@shader-ui/react";
const subscribe = () => new Promise<void>((resolve) => setTimeout(resolve, 1400));
export function Newsletter() {
return (
<Form
guide
onSubmit={(e) => {
e.preventDefault();
return subscribe();
}}
>
<fieldset>
<legend>Topics (optional)</legend>
<label>
<Checkbox name="topics" value="news" /> Library news
</label>
<label>
<Checkbox name="topics" value="a11y" /> Accessibility articles
</label>
</fieldset>
<label>
<Checkbox required /> I accept the privacy policy
</label>
<Button type="submit">Subscribe</Button>
</Form>
);
}Choose delivery
A single choice among four options.
What lights up
- When changing option, light travels through the options in between: motion shows the path of the choice.
- With the keyboard, one hop at a time; from last to first, a direct hop.
- Frames
- 0
- Active effects
- 0
- Renderer
- none
radio.ts
import "@shader-ui/core/styles.css";
import { watchForm } from "@shader-ui/core";
document.body.insertAdjacentHTML(
"beforeend",
`<form id="delivery">
<fieldset>
<legend>Delivery</legend>
<label><input type="radio" name="delivery" value="standard" required> Standard, free</label>
<label><input type="radio" name="delivery" value="express" required> Express, €9.90</label>
<label><input type="radio" name="delivery" value="store" required> In-store pickup</label>
</fieldset>
</form>`,
);
watchForm(document.querySelector<HTMLFormElement>("#delivery")!, { guide: true });Delivery.tsx
import { Form, Radio } from "@shader-ui/react";
export function Delivery() {
return (
<Form guide>
<fieldset>
<legend>Delivery</legend>
<label>
<Radio name="delivery" value="standard" required /> Standard, free
</label>
<label>
<Radio name="delivery" value="express" required /> Express, €9.90
</label>
<label>
<Radio name="delivery" value="store" required /> In-store pickup
</label>
</fieldset>
</Form>
);
}Blog post
The links of a text are revealed in the trail of light, in reading order.
What lights up
- When the reader reaches the passage, a pulse runs through the links in reading order: each takes on its style in the trail. They see at a glance what is clickable.
- Once per link, then the page is still again. With the keyboard, the link is styled as soon as it gets focus.
Why light
An interface reads its state from native HTML: light only doubles it. It follows the accessibility principles of WCAG 2.2, never moves at rest, and steps aside with reduced motion.
Each link takes on its style in the trail, in reading order. Once per link.
- Frames
- 0
- Active effects
- 0
- Renderer
- none
links.ts
import "@shader-ui/core/styles.css";
import { revealLinks } from "@shader-ui/core";
document.body.insertAdjacentHTML(
"beforeend",
`<article id="article">
<p>
An interface reads its state from <a href="https://developer.mozilla.org/docs/Web/HTML">native HTML</a>.
Light follows the <a href="https://www.w3.org/TR/WCAG22/">WCAG 2.2 principles</a>
and steps aside with <a href="https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion">reduced motion</a>.
</p>
</article>`,
);
revealLinks(document.querySelector("#article")!);Article.tsx
import { RevealLinks } from "@shader-ui/react";
export function Article() {
return (
<RevealLinks>
<article>
<p>
An interface reads its state from <a href="https://developer.mozilla.org/docs/Web/HTML">native HTML</a>.
Light follows the <a href="https://www.w3.org/TR/WCAG22/">WCAG 2.2 principles</a>
and steps aside with <a href="https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion">reduced motion</a>.
</p>
</article>
</RevealLinks>
);
}