Last active
April 3, 2024 21:00
-
-
Save glennreyes/5149f994c3d7103db603bdd8f6c3a746 to your computer and use it in GitHub Desktop.
An h1 that can be anything from an h1-h4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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