H1

H1 heading component.

Usage

H1Example.tsx
  1. 1
<H1>This is an H1 heading</H1>

Here's the <H1 /> component in action.

This is an H1 heading

Features

  • Drop-in replacement for the native <h1> element.
  • Opts-in to your design system's typographic styles.

Source

h1.tsx
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
import { type HTMLAttributes, forwardRef } from 'react'
import { cn } from '#app/utils/tailwind-merge.ts'
/**
* A h1 component.
*/
const H1 = forwardRef<HTMLHeadingElement, HTMLAttributes<HTMLHeadingElement>>(({ className, ...props }, ref) => <h1 ref={ref} className={cn('h1', className)} {...props} />)
H1.displayName = 'H1'
export { H1 }

Styling

tailwind.css
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
.h1 {
@apply text-muted-900 mb-fluid-13 text-fluid-4xl max-w-prose font-sans font-bold capitalize;
/* Typographical elements after h1 */
& + .h2,
& + .p {
@apply mt-0;
}
}