Raw
1 import { cva, type VariantProps } from "cva"
2 import * as React from "react"
3
4 import { clx } from "@/utils/clx"
5
6 const headingVariants = cva({
7 base: "font-sans font-medium",
8 variants: {
9 level: {
10 h1: "h1-core",
11 h2: "h2-core",
12 h3: "h3-core",
13 },
14 },
15 defaultVariants: {
16 level: "h1",
17 },
18 })
19
20 interface HeadingProps extends VariantProps<typeof headingVariants>,
21 React.HTMLAttributes<HTMLHeadingElement> {}
22
23 /**
24 * This component is based on the heading element (`h1`, `h2`, etc...) depeneding on the specified level
25 * and supports all of its props
26 */
27 const Heading = ({
28 /**
29 * The heading level which specifies which heading element is used.
30 */
31 level = "h1",
32 className,
33 ...props
34 }: HeadingProps) => {
35 const Component = level || "h1"
36
37 return (
38 <Component
39 className={clx(headingVariants({ level }), className)}
40 {...props}
41 />
42 )
43 }
44
45 export { Heading, headingVariants }