kobaltedev / kobalte

A UI toolkit for building accessible web apps and design systems with SolidJS.
https://kobalte.dev
MIT License
1.2k stars 61 forks source link

Changing the rendered component #18

Closed marbemac closed 1 year ago

marbemac commented 1 year ago

With respect to changing the rendered element, I noticed that Kobalte is using the as pattern. Pros/cons to each, but have you considered the asChild pattern. Radix ended up changing from as to asChild to simplify typings, and improve autocomplete performance in IDEs (and maybe some other reasons, I don't remember TBH): https://www.radix-ui.com/docs/primitives/overview/styling#changing-the-rendered-element

Both work! Just wanted to share the other pattern for consideration while Kobalte is still in the early malleable stages, in case you hadn't already seen it.

Eagerly looking forward to giving Kobalte a spin, whenever it's on NPM.

fabien-ml commented 1 year ago

Hi, i'm aware of the poor autocomplete performance in IDEs of the as prop and don't like it too 😅. I've already looked at radix asChild but I don't think it can be done the same way in solid. The react implementation reply on React.cloneElement and things like child.type === Slottable, but in solid there is on VDOM element to clone in order to merge the props like they does

marbemac commented 1 year ago

Ah ok, fair enough yeah that makes sense. Thanks for the response!