Skip to main content

Heading

The Heading component renders styled heading elements (h1 through h6, or custom tags) with consistent font sizes, weights, and colors using Tailwind CSS utilities. Ideal for maintaining a unified typographic hierarchy in your design system.

πŸ“¦ Import​

import { Heading } from "@sahilphondekar/react-component-library";

🧱 Props​

NameTypeDefaultDescription
aselementType"h1"The HTML heading tag or element to render (h1, h2, ..., div)
sizeOne of: "xs", "sm", "base", "lg", "xl", "2xl", ..., "9xl""2xl"Sets the heading size using Tailwind
weightOne of: "thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black""bold"Font weight class
colorstring"text-gray-900"Tailwind text color class
classNamestring""Additional custom class names
childrennode (required)β€”Content to display inside the heading

πŸš€ Examples​

Basic Usage​

<Heading>Welcome to the Dashboard</Heading>

Custom Size and Tag​

<Heading as="h2" size="3xl">
Section Title
</Heading>

Custom Color and Weight​

<Heading color="text-blue-600" weight="semibold">
Highlighted Heading
</Heading>

πŸ’‘ Best Practices​

  • Use semantic HTML elements (h1 to h6) with the as prop for SEO and accessibility.
  • Stick to your design system's predefined size and weight scales for consistency.
  • Use Heading only for actual titles or section headingsβ€”not for general text.