apps/www/content/docs/components/heading.mdx
import { Heading } from "@chakra-ui/react"
<Heading>I'm a Heading</Heading>
Use the size prop to change the size of the heading component.
Compose the Heading component with the Highlight component to highlight
text.
Use the as prop to render the heading as another HTML element.
Use the fontWeight prop to change the weight of the heading component.
Use the Heading component to compose other components.
:::info
After customizing the recipe, run the CLI typegen command to regenerate the types. See the CLI docs for how to run typegen in postinstall, CI, and monorepos.
npx @chakra-ui/cli typegen
:::
To override the fontSize, we recommend using the textStyle prop since it
considers the line height and letter spacing as well.
Here's an example of customizing the Heading component.
import { createSystem, defaultConfig, defineRecipe } from "@chakra-ui/react"
const headingRecipe = defineRecipe({
base: {
fontWeight: "normal",
textStyle: "4xl",
},
})
const system = createSystem(defaultConfig, {
theme: {
recipes: { heading: headingRecipe },
},
})
To change the default heading font, set the fonts.heading token in your theme.
import { createSystem, defaultConfig } from "@chakra-ui/react"
const system = createSystem(defaultConfig, {
theme: {
tokens: {
fonts: {
heading: { value: "Playfair Display, serif" },
},
},
},
})
Update the variants.size property to create a custom size.
import { createSystem, defaultConfig, defineRecipe } from "@chakra-ui/react"
const headingRecipe = defineRecipe({
variants: {
size: {
custom: {
fontSize: "100px",
lineHeight: "100px",
letterSpacing: "-2px",
},
},
},
})
const system = createSystem(defaultConfig, {
theme: {
recipes: { heading: headingRecipe },
},
})
Then, use the custom variant to create a custom size.
<Heading size="custom">I'm a custom size</Heading>