Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

676 B
Raw Blame
/**
 * @deprecated This component will be replaced by the Element component in the future.
 * Use Element with tag="h1", "h2", etc. instead.
 */
import {
  forwardRef,
  type ElementRef,
  type ComponentProps,
  createElement,
} from "react";
import { getTagFromProps } from "@webstudio-is/sdk/runtime";

const defaultTag = "h1";

type Props = ComponentProps<typeof defaultTag> & {
  tag?: string;
};

export const Heading = forwardRef<ElementRef<typeof defaultTag>, Props>(
  ({ tag: legacyTag, ...props }, ref) => {
    const tag = getTagFromProps(props) ?? legacyTag ?? defaultTag;
    return createElement(tag, { ...props, ref });
  }
);

Heading.displayName = "Heading";