Skip to content

Instantly share code, notes, and snippets.

@glennreyes
Last active April 3, 2024 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennreyes/5149f994c3d7103db603bdd8f6c3a746 to your computer and use it in GitHub Desktop.
Save glennreyes/5149f994c3d7103db603bdd8f6c3a746 to your computer and use it in GitHub Desktop.
An h1 that can be anything from an h1-h4
import type { ComponentPropsWithoutRef, ElementType } from 'react';
type H1Props<TElementType extends ElementType> = Omit<ComponentPropsWithoutRef<TElementType>, 'className'> & {
as?: Extract<TElementType, 'h1' | 'h2' | 'h3' | 'h4'>;
};
export function H1<TElementType extends ElementType>({ as, ...props }: H1Props<TElementType>) {
const Component = as ?? 'h1';
return <Component className="text-5xl font-extrabold tracking-tight" {...props} />;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment