I spend probably too much time wondering how much a component should decide on its own.
I’m not dreaming of a component that decides what somebody’s site should look like, or what they’re trying to say with it, but I would just really prefer it if they’d take care of essential things on their. Especially the sort of accessibility things that can otherwise get lost in the hustle bustle of development.
Ideally, I think it would kind of work like the headlights on most cars these days. You set them to auto so that they come on when it gets dark and then you never have to think about it again. But if you do need them on when it’s still light out, you can still do that with a simple twist of the swtich. Ditto for when you need them off while the car is running at night.
I want components like that. Things that come to work understanding the assignment, but smoothly change course when you need it to do something else. Good accessibility practices can then be baked in as the default state and not something that needs to be remembered to manually set up for each and every instance.
The wave dream
My
I was fixated on creating a curvy divider that didn’t curve in the same ways every time the page loaded. A wave between a header and its content might have three humps one time and four the next. Nothing dramatic, but enough variation to make the page feel almost… alive. Or at least, moreso than it would have with an SVG I’d drawn once, copy/pasted into the code, and then left there for the rest of time and all eternity.
So I started learning how to generate path options with code instead of drawing them in an SVG editor (paths are little snippets of code that tell the SVG how to draw a line. In my case, curvy). The early versions were rougher than where the library is at now, but one idea has been consistent from the beginning: dynamowaves are purely decoration. They don’t explain the content above or below them. They don’t signal warnings or errors. They merely exists to give a page a little more life and have some fun with it.
I think that’s a perfectly fine reason to put something on a page.
I feel like there’s a tendency, especially once you start really understanding and embracing web accessibility, to treat anything decorative as automatically frivolous and to throw it on the chopping block. I’m not sure I buy that. A thing can be unnecessary and still be part of crafting a visual experience that feels considered, welcoming, or engaging. The wave doesn’t have a job on the page and doesn’t need one. It’s when it start showing up for jobs it isn’t qualified for that the trouble starts.
If the divider is solely visual decoration, then logic follows that it should, uh, stay visual. It shouldn’t become a strange interruption for a screen reader. It shouldn’t turn into yet another tab stop in the way of the content someone came for. It shouldn’t provide information that is inaccessible to anyone who can’t see it.
That part was built into
Then it started to move
Sweet, silky animations came later.
Once the wave could dynamically generate its own unique shapes, it was a short leap to my fixatation latching on to imagining what would happen if it could animate between them. A slowly flowing divider sounded a whole lot cooler than just a different one on each visit.
Movement made its status as decorative a bit more complicated though. A static wave is just a piece of the page, but a moving one is constantly (even if subtly) asking for attention. And for people with motion sensitivity, that can quickly ruin the entire experience you’ve been trying to build.
Luckily, the browser has our back. Anyone can ask their operating system to reduce motion and when that preference is on, the browser lets your site know with a simple flag. The prefers-reduced-motion setting is on? The wave will pause itself and become just another static part of the page.
Remembering to manually set the code and attributes necessary to maintain proper accessiblity honestly doesn’t take that long for any individual component, but it’s the sort of thing that tends to slip when you have an entire form’s of worth fields you were supposed to have been done building out yesterday. Or when you’re “just prototyping” and have every intention of finding the time you’ll need to come back and polish things up before it’s deployed to production. Or if you forget to tell your agent to code like an a11y.
Having a component handy that understands what it is and acts accordingly out-of-the-box can help save you from the lapses.
Six gotchas to watch for
A preference is read once (and only once)
The component checks reduced motion on startup, but the user changes a site setting or their system preferences while the page is open.
Fix:Treat preferences as live state: listen for system changes and allow for overrides to be set by the page itself.
Preferring reduced motion means removing feedback
It's too easy to blanket remove every transition and accidentally make a press, selection, or expanded state appear to do nothing.
Fix:Pause decorative motion, but preserve feedback through color, border, opacity, or an immediate non-moving change.
A focus ring is technically there, but hidden from view
An ancestor uses a class that hides any overflow, a scrolling container is clipping the outline, or a transformed layer has shoved it behind something else.
Fix:Give focus treatment enough inset/offset and stacking room to remain visible within a specific component's layout. You're going to have to actually play with the rendered page to double check this one.
Closing a dialog restores focus to... nowhere
Your dialog destroys properly, but no logic exists to tell focus where it should return. Or, the logic exists but the focus return target doesn't yet thanks to conditional render timing.
Fix:Restore focus to the trigger when possible (search or wait for it if you have to). Otherwise, provide a deliberate fallback to the previous item in the tab index.
IDs and labels duplicate when the component is used twice on the same page
You remembered to provide IDs and proper labeling for your textbox component, but they're hardcoded as a static value. That's fine for a one-off, but use more than one on a page and the IDs collide.
Fix:Generate stable, component-instance-specific IDs inside the component logic and wire the label, description, and error state together there as well.
A custom control disappears when things go high-contrast
The component relies on a background image, mask, shadow, or carefully chosen token that the reader’s environment replaces or straight up ignores.
Fix:Provide a forced-color-safe shape, border, and text treatment so the control still has a visible state when the palette is being served up by the system itself.
Skip to the recipe
A CSS media query is amazing for handling motion controlled by your stylesheets, but anything powered by JavaScript is left in the dark unless it explicitly asks. And even then, reading the preference once gives you a snapshot that goes stale the moment someone flips the setting. The fix is to define it once, then listen for the change event an your new scoped variable.
const query = window.matchMedia('(prefers-reduced-motion: reduce)');
// true when motion should stop, false when it can run
let reduceMotion = query.matches;
// Fires whenever the OS setting flips while the page is open
query.addEventListener('change', (event) => {
reduceMotion = event.matches;
});Anything with nonessential motion can check reduceMotion before it animates. If something needs to react the moment the setting changes, like pausing a running loop, do that work inside the change handler too.
Good defaults are not a free pass
So that we’re clear though, good defaults don’t solve accessibility infractions all on their own forever. There are always decisions a component can’t make from inside itself that are going to need a judgement call. Whether something is genuinely decorative or informative is a design call. Whether motion is helping someone understand a state or just making a page feel fun is another one. A sensible default offers a strong starting point, but it can’t do the thinking for you (yet).
What it can do, though, is remove the needless, repetitive version of the work. It can keep known good behavior from being overlooked or added to the “we’ll get there someday” polish list and it can make the right behavior the ordinary behavior, without requiring everyone building with it to have a working knowledge of accessibility best practices in addition to their dev skills.
I love when a component feels complete enough to not only be able to be used anywhere, but to also take responsibility for the parts it’s qualified to own and help get accessible patterns out to the folks who need them. Whether somebody was able to remember to add them in or not.