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>
);
}When to use it
- On the body of a text: article, documentation, product description.
- Not on navigation, menus or footers: those links are already identified by their place. Nor on a page where almost everything is a link (results, table of contents).
Recommendations
- If your links are styled by an id or with !important, they keep their style and are not revealed: target [data-sui-link] to fix it.
- For a single link to draw attention to ("Resend the code"), <Light reveal> rather than a whole container.
Accessibility
The library
- Links stay links, announced by screen readers. The text is never hidden, the layout never moves.
- On keyboard focus, the link is revealed at once.
- Once per link, a wave of 5 s at most, counted as a single effect.
- Reduced motion: a 200 ms fade. High contrast, without JS or without IntersectionObserver: the site's style.
- Nothing is stored: no reading history.
Integration
- A link style that stands out without color (underline) or with 3:1 contrast against the text: that is what the library reveals.
- Before the pass, the link looks like text for at least 500 ms. For an essential link: initial="link".
- Explicit link text, no "click here".
WCAG 2.2 criteria: Use of Color · Pause, Stop, Hide · Three Flashes or Below Threshold · Animation from Interactions · Link Purpose (In Context)
Props
| Prop | Type | Purpose |
|---|---|---|
<RevealLinks> | children | A single element: the container of the links (article, description). |
ignore | string | CSS selector of the links to ignore. Also: data-sui-ignore on a parent. |
initial | "text" | "link" | Before the pass: the look of the text (default), or already the link style. |
speed | number | Speed of the pulse in px/s: 600 by default, from 100 to 2,000. In HTML: data-sui-speed. |
<Light reveal> | <a> | A single link you want to draw attention to. |
--sui-link-light | CSS | Color of the pulse, the accent by default. |
Spec
The normative spec for this component: Liens révélés
Availability and resources
- Status
- available · open source
- Packages
- @shader-ui/react (React, Next.js)
@shader-ui/core (TypeScript, plain HTML) - Source code
- reveal-links.ts (core) · RevealLinks.tsx (React) · Light.tsx (React)