r/webdev • • 19d ago

Discussion What if UI components were built more like modular phones?

I've been thinking about how we build UI components and whether we're treating them as bigger units than they need to be.

A dropdown, for instance, isn't just a dropdown. It involves popup positioning, keyboard navigation, focus management, selection, and dismissal. What if these behaviours were independent building blocks that could be combined to create different kinds of components?

I explore this idea in the context of recently released Vercel's UI SDK and, more interestingly, how AI agents could interact with components through something like an Agent Bridge.

It's an interesting direction for component architecture, especially as AI agents become more involved in working with web interfaces.

Would love to hear what you think!

https://amitmerchant.com/what-if-ui-components-were-built-like-modular-phones/

0 Upvotes

8 comments sorted by

9

u/Puzzleheaded-Work903 19d ago

thats what ui kit is... i dont understand your point nor will to make more complex

4

u/Gremlation 19d ago

I don't see why you think this metaphor works. "Remember that idea that completely failed to take off in any way whatsoever? Let's try that!"

2

u/w-lfpup 19d ago

The main challenge is many behaviors like focus and keyboard navigation and selection are tightly coupled to the a11y tree parsed by the browser.

An even worse challenge is behaviors like selection and dismissal are tightly coupled to app state.

And in large scale UI projects there's this pattern where the more specified a component is the less it's used. EVERY project will use more buttons than checkboxes than text inputs than calendar inputs. So chunking up big complicated elements sounds logical but doesn't scale well.

2

u/Vast_Work5283 19d ago

great until the lego set needs its own instruction manual

1

u/Fancy_Let4203 18d ago

Interesting way to say UI framework with loose coupling properties/fields

1

u/acefolio_dev 18d ago

This already exists in a few headless libraries. React Aria splits the behaviors into hooks like usePress, useSelect and useOverlayTrigger, and Radix and Base UI ship the same pieces as unstyled primitives. The part that gets tricky is the one w-lfpup mentioned, focus and selection tend to need the actual DOM structure, so the pieces compose best when each one owns its own element.

1

u/Itchy-Ask4565 17d ago

the modularity makes sense, but focus management and dismissal are so tightly coupled in practice that splitting them too far just moves the complexity into glue code