HeadlinesBriefing favicon HeadlinesBriefing.com

Why Reشوندّ Creating Buttons From Scratch is a Bad Idea

Hacker News •
×

Title riffs on a Carl Sagan quote and hooks into a thought exercise. When learning web accessibility, the first thing we hear is “do not use ARIA” and “use native elements instead of recreating them.” The article explains why.

Native elements carry UX expectations. The article lists button requirements from MDN, APG, ARIA spec, and WCAG 2.2, including role, accessible label, focusability, mouse/touch/keyboard activation, form behavior, validation, disabled state, and newer APIs.

It then walks through creating a custom <sagan-button> element: add role=button, aria-label, tabindex=0, and event listeners for mouseup, touchend, pointerup. Styling is omitted, but the example demonstrates how to expose the element to the accessibility tree and make it operable.

Finally a JavaScript class attaches a Shadow DOM, sets internals, and centralises event handling. The piece concludes that recreating elements is a Sisyphean task and encourages using native elements for accessibility.