Components, that are only used as layout component or not necessarily need to be a specific element, could be polymorphic. Types for these components are a bit more complicated. So here is an example of how to handle polymorphic as-prop in react components.
import type { PolymorphicComponent } from "@dnshpf/ts-utils";
const Box: PolymorphicComponent<"div"> = ({ as: As, ...props }) => {
const Component = As || "div";
return <Component {...props} />;
}
Generated using TypeDoc
The default element type used in the component (e.g. "div")