mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
23 lines
523 B
TypeScript
23 lines
523 B
TypeScript
import {
|
|
forwardRef,
|
|
createElement,
|
|
type ElementRef,
|
|
type ComponentProps,
|
|
} from "react";
|
|
import { getTagFromProps } from "@webstudio-is/sdk/runtime";
|
|
|
|
const defaultTag = "div";
|
|
|
|
type Props = ComponentProps<typeof defaultTag> & {
|
|
tag?: string;
|
|
};
|
|
|
|
export const Text = forwardRef<ElementRef<typeof defaultTag>, Props>(
|
|
({ tag: legacyTag, ...props }, ref) => {
|
|
const tag = getTagFromProps(props) ?? legacyTag ?? defaultTag;
|
|
return createElement(tag, { ...props, ref });
|
|
}
|
|
);
|
|
|
|
Text.displayName = "Text";
|