H3

H3 heading component.

Usage

H3Example.tsx
  1. 1
<H3>This is an h3 heading</H3>

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

This is an h3 heading

Features

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

Parts and their API

Source

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

Styling

tailwind.css
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
.h3 {
@apply text-muted-900 mt-fluid-14 mb-fluid-9 text-fluid-2xl max-w-prose font-sans font-bold capitalize;
/* If h3 has h4 after it */
&:has(+ .h4) {
@apply mb-fluid-8;
}
/* Typographical elements after h3 */
& + .h4,
& + .p {
@apply mt-0;
}
}