Docs
GradientHeading

GradientHeading

A cool gradient heading component

Variant: default

Heading - lg

Heading - lg

Heading - lg

Heading - lg

Heading - lg

Heading - xl

Heading - xl

Heading - xl

Heading - xl

Heading - xl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Variant: pink

Heading - lg

Heading - lg

Heading - lg

Heading - lg

Heading - lg

Heading - xl

Heading - xl

Heading - xl

Heading - xl

Heading - xl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Variant: light

Heading - lg

Heading - lg

Heading - lg

Heading - lg

Heading - lg

Heading - xl

Heading - xl

Heading - xl

Heading - xl

Heading - xl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Heading - xxxl

Installation

Copy and paste the following code into your project.

import React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
 
import { cn } from "@/lib/utils"
 
const headingVariants = cva(
  "tracking-tight pb-3 bg-clip-text text-transparent",
  {
    variants: {
      variant: {
        default:
          "bg-gradient-to-t from-neutral-700 to-neutral-800 dark:from-stone-200 dark:to-neutral-200",
        pink: "bg-gradient-to-t from-accent to-accent/90 dark:from-stone-200 dark:to-neutral-200",
        light: "bg-gradient-to-t from-neutral-200 to-neutral-300",
        secondary:
          "bg-gradient-to-t from-primary-foreground to-muted-foreground",
      },
      size: {
        default: "text-2xl sm:text-3xl lg:text-4xl",
        xxs: "text-base sm:text-lg lg:text-lg",
        xs: "text-lg sm:text-xl lg:text-2xl",
        sm: "text-xl sm:text-2xl lg:text-3xl",
        md: "text-2xl sm:text-3xl lg:text-4xl",
        lg: "text-3xl sm:text-4xl lg:text-5xl",
        xl: "text-4xl sm:text-5xl lg:text-6xl",
        xxl: "text-5xl sm:text-6xl lg:text-[6rem]",
        xxxl: "text-5xl sm:text-6xl lg:text-[8rem]",
      },
      weight: {
        default: "font-bold",
        thin: "font-thin",
        base: "font-base",
        semi: "font-semibold",
        bold: "font-bold",
        black: "font-black",
      },
    },
    defaultVariants: {
      variant: "default",
      size: "default",
      weight: "default",
    },
  }
)
 
export interface HeadingProps extends VariantProps<typeof headingVariants> {
  asChild?: boolean
  children: React.ReactNode
  className?: string
}
 
const GradientHeading = React.forwardRef<HTMLHeadingElement, HeadingProps>(
  ({ asChild, variant, weight, size, className, children, ...props }, ref) => {
    const Comp = asChild ? Slot : "h3" // default to 'h3' if not a child
    return (
      <Comp ref={ref} {...props} className={className}>
        <span className={cn(headingVariants({ variant, size, weight }))}>
          {children}
        </span>
      </Comp>
    )
  }
)
 
GradientHeading.displayName = "GradientHeading"
 
// Manually define the variant types
export type Variant = "default" | "pink" | "light" | "secondary"
export type Size =
  | "default"
  | "xxs"
  | "xs"
  | "sm"
  | "md"
  | "lg"
  | "xl"
  | "xxl"
  | "xxxl"
export type Weight = "default" | "thin" | "base" | "semi" | "bold" | "black"
 
export { GradientHeading, headingVariants }

Update the import paths to match your project setup.

Usage

import { GradientHeading } from "@/components/ui/gradient-heading"
export default function GradientHeadingExample() {
  return (
    <GradientHeading variant="default" size="lg" weight="bold">
      Like and subscribe
    </GradientHeading>
  )
}