Reusable React Tailwind Section Heading Components - 3 Unique Styles with TypeScript Support
No matter what app we are working on, we need section headings, since all apps have sections.
If we talk about blogs, e-commerce sites, landing pages, dashboards, agency pages, all kinds of apps consist of sections, and not all but some sections need section headings.
In section headings, we have a title (section title) and a subtitle (a little bit of description of the title). The subtitle is optional.
I'm sharing three versions of section headings and will update this page from time to time by adding new variants.
Why use these section heading components?
- Easy to integrate into any React project
- Built with Tailwind CSS for quick customization
- TypeScript support for better type safety and code predictability
Section Heading Version 1 | Minimal Colors Heading
Since the section heading component is built using TypeScript, the interface needs two props: title
and subtitle
, and both are strings.
Result UI
This is how our minimal colors section heading UI will look.
Tailwind CSS Section Heading Version 1 Code
import { FC } from 'react' interface SectionHeadingProps { title: string subtitle?: string } const SectionHeading: FC<SectionHeadingProps> = ({ title, subtitle }) => ( <div className="my-7"> <h2 className="text-2xl font-bold text-stone-900">{title}</h2> {subtitle && <p className="text-slate-500">{subtitle}</p>} </div> ) export default SectionHeading
Use Case
<SectionHeading title="Latest Articles" subtitle="Diverse Range of articles related to html css and javascript" />
Section Heading Version 2 | Colored Heading
This version also needs two props, but title is an array of strings. We pass the title like this: ['Latest', 'Articles']
. According to our logic, the second element of the title (index 1) will be colored.
If you have a longer title with more than two words, you need to adjust the title to fit your aesthetic.
Result UI
Result of colored Heading UI.
Tailwind CSS Section Heading Version 2 Code
import { FC } from 'react' interface SectionHeadingProps { title: string[] subtitle?: string } const SectionHeading: FC<SectionHeadingProps> = ({ title, subtitle }) => ( <div className="my-7"> <h2 className="text-2xl font-bold text-[#161616]"> {title[0]} <span className="text-[#63D471]">{title[1]}</span> </h2> {subtitle && <p className="text-gray-600">{subtitle}</p>} </div> ) export default SectionHeading
Use Case
<SectionHeading title={['Latest', 'Articles']} subtitle="Diverse Range of articles related to html css and javascript" />
Section Heading Version 3 | Detailed Center Heading
The interface needs three props: title
, subtitle
and shortDescription
, and all of them are strings. You can adjust it as per your need.
Result UI
This is how our Detailed Center Heading UI will look.
Tailwind CSS Detailed Center Heading Code
interface SectionHeadingTypes { title: string subtitle: string shortDescription: string } const SectionHeading: React.FC<SectionHeadingTypes> = ({ title, subtitle, shortDescription, }) => { return ( <div className="mx-auto my-7 max-w-lg text-center"> <h2 className="mb-2.5 text-sm font-bold uppercase tracking-wider text-[#4491FB]"> {title} </h2> <h3 className="text-3xl font-semibold text-stone-900">{subtitle}</h3> <p className="mt-4 text-lg text-slate-500">{shortDescription}</p> </div> ) } export default SectionHeading
Use Case
<SectionHeading title="Featured Categories" subtitle="Shop by Category" shortDescription="Explore our curated collection of top products and discover the perfect items for your needs" />
If you found this resource helpful, don’t forget to share it with your network and explore more React components in our library. You can also share your opinion on LinkedIn.