createProxy
createProxy builds component families like Show.div or For.ul, and it can be used externally to create your own proxy components. The steps below walk through a Custom Clickable example.
Define props and base behavior#
Start by defining a base component that contains the shared behavior. The proxy reuses this base for every tag.
Why BaseClickableType<X = object>? The proxy must accept your custom props plus whatever props belong to each tag or registered component. X is the placeholder for those tag props, and X & ClickableProps merges them. The default object keeps the base usable without extra props. Without the generic, variants like Clickable.div would lose native props such as className, href, or role at the type level.
Add renderForTag + ProxyType#
Provide a tag renderer and declare the proxy type so tag variants like Clickable.div are typed.
Why BaseClickableFn extends BaseTypeHelperFn and this["props"]? ProxyType treats BaseTypeHelperFn as a type-level function. It injects each tag's props into the props slot, then evaluates type to produce the final call signature. Using this["props"] makes the signature depend on the tag, so Clickable.div gets ComponentPropsWithRef<"div"> merged with ClickableProps, while Clickable.Link picks up registered component props. If you hardcode ClickableProps here, the tag-specific props will not flow through.
Register custom components (optional)#
Register components under a category and augment UtilinentRegister for type-safe Clickable.* usage.
Usage examples#
Use the default component or tag/component variants once registered.