DEV Community

Ryan Westlund
Ryan Westlund

Posted on • Originally published at

"Enhanced" basic web components

So browsers have <button>, <input>, <select> and all the other essential UI elements as built-in, styleable components. Admittedly they don't look very nice. But one thing I really disagree with about the direction the web ecosystem seems to be going is the fad of "enhanced" versions of these, like most of the MWC components. There's an <mwc-button>, an <mwc-textfield> (equivalent of <input>, because why not rename a couple of them too for extra confusion), an <mwc-textarea>, <mwc-formfield> which basically fills the purpose of <label> but is less flexible (it can't contain HTML), and a whole bunch more.

Before MWC, at my job we used the Polymer components: paper-*, iron-*, and app-* stuff. They were nice: they looked nice, they were a nice fat sack of dependencies, and the users liked 'em. But they're deprecated and we're trying to switch to the new MWC stuff. The new MWC stuff looks nice, is a nice fat sack of dependencies, has different interfaces and the users like them. But they've also introduced some issues.

Like the ugly hack we've had to come up with to make <mwc-textarea> autoexpand. We've applied that hack in several places, and one day it stopped working after we updated minor versions and its internal HTML structure had changed, so I spent about an hour to figure out how the hack needed to be amended. This does also require a Javascript fix for the native element, but it's much simpler, doesn't require peeking inside shadow DOM, and won't break when your library updates.

I just think the whole idea of enhanced basic web components is wrong-headed. Maybe it does make sense in marketing terms to use them on your website if users like the look. But for the love of simplicity, I think we'd all be better off if we just stuck to the built-in components, and one of two things would happen: either the browser vendors would implement nicer default styling, or users would learn to not mind them. Kind of a prisoner's dilemma, maybe.

Originally published at

Discussion (0)