Search

Headings

Astro - Heading levels

Responsive component for different heading levels, With Tailwind CSS

Props Interface

Simplified to include only level for the heading level and classes for additional classes.

Conditional Rendering

Renders the appropriate heading tag (h1 to h6) based on the level prop.

Tailwind Classes

Uses Tailwind CSS classes for responsive typography:
  • Base size: text-2xl, text-xl, text-lg, etc.
  • Medium size (min-width: 640px): sm:text-3xl, sm:text-2xl, sm:text-xl, etc.
  • Large size (min-width: 768px): md:text-4xl, md:text-3xl, md:text-2xl, etc.
  • Font Weight: font-bold for bold text.
---
import HeadingTW from '/src/components/HeadingTW.astro'
---

<HeadingTW level={1} classes='text-amber-400'> This is a responsive heading 1 </HeadingTW>
<HeadingTW level={2}> This is a responsive heading 2 </HeadingTW>
<HeadingTW level={3}> This is a responsive heading 3 </HeadingTW>
<HeadingTW level={4}> This is a responsive heading 3 </HeadingTW>
<HeadingTW level={5}> This is a responsive heading 3 </HeadingTW>
<HeadingTW level={6}> This is a responsive heading 3 </HeadingTW>